From: Eric Biggers <ebiggers@kernel.org>
To: GUO Zihua <guozihua@huawei.com>
Cc: linux-crypto@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
herbert@gondor.apana.org.au, davem@davemloft.net,
catalin.marinas@arm.com, will@kernel.org
Subject: Re: [PATCH v2] arm64/crypto: poly1305 fix a read out-of-bound
Date: Wed, 20 Jul 2022 19:34:18 -0700 [thread overview]
Message-ID: <Yti7KsIsyRU/+N7w@sol.localdomain> (raw)
In-Reply-To: <20220712075031.29061-1-guozihua@huawei.com>
On Tue, Jul 12, 2022 at 03:50:31PM +0800, GUO Zihua wrote:
> int init(void)
> {
> struct crypto_shash *tfm = NULL;
> struct shash_desc *desc = NULL;
> char *data = NULL;
>
> tfm = crypto_alloc_shash("poly1305", 0, 0);
> desc = kmalloc(sizeof(*desc) + crypto_shash_descsize(tfm), GFP_KERNEL);
> desc->tfm = tfm;
>
> data = kmalloc(POLY1305_KEY_SIZE - 1, GFP_KERNEL);
> memcpy(data, test_data, POLY1305_KEY_SIZE - 1);
> crypto_shash_update(desc, data, POLY1305_KEY_SIZE - 1);
> crypto_shash_final(desc, data);
> kfree(data);
> return 0;
> }
This isn't actually a valid test case since it never calls crypto_shash_init().
So the behavior of this test is undefined both before and after this patch. The
simplest way to write a correct test would be to use crypto_shash_tfm_digest().
Anyway, the bug is still real and this patch is still the correct fix, so it's
good enough to add my reviewed-by:
Reviewed-by: Eric Biggers <ebiggers@google.com>
- Eric
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
prev parent reply other threads:[~2022-07-21 2:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-12 7:50 [PATCH v2] arm64/crypto: poly1305 fix a read out-of-bound GUO Zihua
2022-07-15 2:07 ` Guozihua (Scott)
2022-07-19 8:03 ` Guozihua (Scott)
2022-07-20 9:41 ` Will Deacon
2022-07-20 9:57 ` Guozihua (Scott)
2022-07-21 2:37 ` Eric Biggers
2022-07-21 9:28 ` Will Deacon
2022-07-22 3:14 ` Guozihua (Scott)
2022-07-21 2:34 ` Eric Biggers [this message]
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=Yti7KsIsyRU/+N7w@sol.localdomain \
--to=ebiggers@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=davem@davemloft.net \
--cc=guozihua@huawei.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-crypto@vger.kernel.org \
--cc=will@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox