From: Herbert Xu <herbert@gondor.apana.org.au>
To: Su Hui <suhui@nfschina.com>
Cc: davem@davemloft.net, linux-crypto@vger.kernel.org,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH] crypto: using size_add() for kmalloc()
Date: Mon, 21 Apr 2025 20:05:43 +0800 [thread overview]
Message-ID: <aAY0lyWzsRVDge_f@gondor.apana.org.au> (raw)
In-Reply-To: <20250421055104.663552-1-suhui@nfschina.com>
On Mon, Apr 21, 2025 at 01:51:06PM +0800, Su Hui wrote:
>
> @@ -433,7 +434,7 @@ static inline struct aead_request *aead_request_alloc(struct crypto_aead *tfm,
> {
> struct aead_request *req;
>
> - req = kmalloc(sizeof(*req) + crypto_aead_reqsize(tfm), gfp);
> + req = kmalloc(size_add(sizeof(*req), crypto_aead_reqsize(tfm)), gfp);
This is just wrong. You should fail the allocation altogether
rather than proceeding with a length that is insufficient.
However, reqsize shouldn't be anywhere near overflowing in the
first place. If you're truly worried about this, you should
change the algorithm registration code to check whether reqsize
is sane.
And that needs to wait until the algorithms are fixed to not use
dynamic reqsizes.
Cheers,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
next prev parent reply other threads:[~2025-04-21 12:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-21 5:51 Su Hui
2025-04-21 6:27 ` Su Hui
2025-04-21 7:10 ` Christophe JAILLET
2025-04-21 7:43 ` Su Hui
2025-04-21 8:32 ` Christophe JAILLET
2025-04-21 8:46 ` Su Hui
2025-04-21 8:50 ` Su Hui
2025-04-21 12:05 ` Herbert Xu [this message]
2025-04-22 1:30 ` Su Hui
2025-04-22 10:24 ` Dan Carpenter
2025-04-22 14:16 ` Herbert Xu
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=aAY0lyWzsRVDge_f@gondor.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=davem@davemloft.net \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=suhui@nfschina.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®