OSDN Git Service

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)
commit3ee50c896d712dc2fc8f34c2cd1918d035e74045
tree37183552f664b04bd57d5d75ad1f0624759ba9b4
parent7de4c2bd196f111e39cc60f6197654aff23ba2b4
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