]> git.baikalelectronics.ru Git - kernel.git/commit
crypto: qce - save a sg table slot for result buf
authorEneas U de Queiroz <cotequeiroz@gmail.com>
Fri, 20 Dec 2019 19:02:15 +0000 (16:02 -0300)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 27 Dec 2019 10:18:04 +0000 (18:18 +0800)
commitce7c8967da926f46b81466cf9a2247c9af6436fb
tree37183552f664b04bd57d5d75ad1f0624759ba9b4
parent7897c7276e5619a9c8ac2bf64b1ec9e4540670e6
crypto: qce - save a sg table slot for result buf

When ctr-aes-qce is used for gcm-mode, an extra sg entry for the
authentication tag is present, causing trouble when the qce driver
prepares the dst-results sg table for dma.

It computes the number of entries needed with sg_nents_for_len, leaving
out the tag entry.  Then it creates a sg table with that number plus
one, used to store a result buffer.

When copying the sg table, there's no limit to the number of entries
copied, so the extra slot is filled with the authentication tag sg.
When the driver tries to add the result sg, the list is full, and it
returns EINVAL.

By limiting the number of sg entries copied to the dest table, the slot
for the result buffer is guaranteed to be unused.

Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/qce/dma.c
drivers/crypto/qce/dma.h
drivers/crypto/qce/skcipher.c