All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Stephan Müller" <smueller@chronox.de>
To: herbert@gondor.apana.org.au
Cc: stable@vger.kernel.org, linux-crypto@vger.kernel.org
Subject: [PATCH] crypto: authenc - cryptlen must be at least AAD len
Date: Wed, 06 Sep 2017 21:22:44 +0200	[thread overview]
Message-ID: <4634467.01PS30tDXi@positron.chronox.de> (raw)

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

             reply	other threads:[~2017-09-06 19:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-06 19:22 Stephan Müller [this message]
2017-09-06 20:10 ` [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  3:54     ` Herbert Xu
2017-09-07  5:48     ` Stephan Müller
2017-09-07  6:01       ` Herbert Xu
2017-09-07  6:01         ` Herbert Xu
2017-09-07  6:04         ` Stephan Mueller
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4634467.01PS30tDXi@positron.chronox.de \
    --to=smueller@chronox.de \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.