Linux cryptographic layer development
 help / color / mirror / Atom feed
* [PATCH] crypto: authenc - cryptlen must be at least AAD len
@ 2017-09-06 19:22 Stephan Müller
  2017-09-06 20:10 ` Stephan Müller
  0 siblings, 1 reply; 9+ messages in thread
From: Stephan Müller @ 2017-09-06 19:22 UTC (permalink / raw)
  To: herbert; +Cc: stable, linux-crypto

With AF_ALG, AAD len and cryptlen can be set freely by unprivileged
user space. The cipher implementation must therefore validate the input
data for sanity. For AEAD ciphers, this implies that cryptlen must be
at least as large as AAD size.

This fixes a kernel crash that can be triggered via AF_ALG detected by
the fuzzing test implemented with libkcapi.

CC: <stable@vger.kernel.org>
CC: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Stephan Mueller <smueller@chronox.de>
---
 crypto/authenc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/crypto/authenc.c b/crypto/authenc.c
index 875470b0e026..21e202fc32c1 100644
--- a/crypto/authenc.c
+++ b/crypto/authenc.c
@@ -209,6 +209,9 @@ static int crypto_authenc_encrypt(struct aead_request *req)
 	struct scatterlist *src, *dst;
 	int err;
 
+	if (req->assoclen > cryptlen)
+		return -EINVAL;
+
 	src = scatterwalk_ffwd(areq_ctx->src, req->src, req->assoclen);
 	dst = src;
 
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-09-08 23:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-06 19:22 [PATCH] crypto: authenc - cryptlen must be at least AAD len Stephan Müller
2017-09-06 20:10 ` Stephan Müller
2017-09-07  3:54   ` Herbert Xu
2017-09-07  5:48     ` Stephan Müller
2017-09-07  6:01       ` Herbert Xu
2017-09-07  6:04         ` Stephan Mueller
2017-09-07  6:09           ` Herbert Xu
2017-09-08 22:20         ` [PATCH v2] crypto: add NULL check to scatterwalk_start Stephan Müller
2017-09-08 23:01           ` Stephan Müller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox