aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Mueller <smueller@chronox.de>2016-12-01 02:22:37 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2016-12-01 08:06:44 -0500
commit5937d81a9613a98381c1571a159ac971ae02182c (patch)
tree037fb547505846438c65f8afb8517f29654bba50
parentefad2b61ae258df4fb3896f5e7cd9c701f4979e6 (diff)
crypto: algif_aead - fix AIO handling of zero buffer
Handle the case when the caller provided a zero buffer to sendmsg/sendpage. Such scenario is legal for AEAD ciphers when no plaintext / ciphertext and no AAD is provided and the caller only requests the generation of the tag value. Signed-off-by: Stephan Mueller <smueller@chronox.de> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--crypto/algif_aead.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/crypto/algif_aead.c b/crypto/algif_aead.c
index 80a0f1a78551..6e9513701533 100644
--- a/crypto/algif_aead.c
+++ b/crypto/algif_aead.c
@@ -448,12 +448,13 @@ static int aead_recvmsg_async(struct socket *sock, struct msghdr *msg,
448 used -= ctx->aead_assoclen + (ctx->enc ? as : 0); 448 used -= ctx->aead_assoclen + (ctx->enc ? as : 0);
449 449
450 /* take over all tx sgls from ctx */ 450 /* take over all tx sgls from ctx */
451 areq->tsgl = sock_kmalloc(sk, sizeof(*areq->tsgl) * sgl->cur, 451 areq->tsgl = sock_kmalloc(sk,
452 sizeof(*areq->tsgl) * max_t(u32, sgl->cur, 1),
452 GFP_KERNEL); 453 GFP_KERNEL);
453 if (unlikely(!areq->tsgl)) 454 if (unlikely(!areq->tsgl))
454 goto free; 455 goto free;
455 456
456 sg_init_table(areq->tsgl, sgl->cur); 457 sg_init_table(areq->tsgl, max_t(u32, sgl->cur, 1));
457 for (i = 0; i < sgl->cur; i++) 458 for (i = 0; i < sgl->cur; i++)
458 sg_set_page(&areq->tsgl[i], sg_page(&sgl->sg[i]), 459 sg_set_page(&areq->tsgl[i], sg_page(&sgl->sg[i]),
459 sgl->sg[i].length, sgl->sg[i].offset); 460 sgl->sg[i].length, sgl->sg[i].offset);