From: "Guozihua (Scott)" <guozihua@huawei.com>
To: Will Deacon <will@kernel.org>
Cc: <linux-crypto@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<herbert@gondor.apana.org.au>, <davem@davemloft.net>,
<catalin.marinas@arm.com>, <ebiggers@kernel.org>
Subject: Re: [PATCH v2] arm64/crypto: poly1305 fix a read out-of-bound
Date: Wed, 20 Jul 2022 17:57:30 +0800 [thread overview]
Message-ID: <a29cb083-0305-3467-976c-e541daefc5e8@huawei.com> (raw)
In-Reply-To: <20220720094116.GC15752@willie-the-truck>
On 2022/7/20 17:41, Will Deacon wrote:
> On Tue, Jul 12, 2022 at 03:50:31PM +0800, GUO Zihua wrote:
>> A kasan error was reported during fuzzing:
>
> [...]
>
>> This patch fixes the issue by calling poly1305_init_arm64() instead of
>> poly1305_init_arch(). This is also the implementation for the same
>> algorithm on arm platform.
>>
>> Fixes: f569ca164751 ("crypto: arm64/poly1305 - incorporate OpenSSL/CRYPTOGAMS NEON implementation")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: GUO Zihua <guozihua@huawei.com>
>> ---
>> arch/arm64/crypto/poly1305-glue.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> I'm not a crypto guy by any stretch of the imagination, but Ard is out
> at the moment and this looks like an important fix so I had a crack at
> reviewing it.
>
>> diff --git a/arch/arm64/crypto/poly1305-glue.c b/arch/arm64/crypto/poly1305-glue.c
>> index 9c3d86e397bf..1fae18ba11ed 100644
>> --- a/arch/arm64/crypto/poly1305-glue.c
>> +++ b/arch/arm64/crypto/poly1305-glue.c
>> @@ -52,7 +52,7 @@ static void neon_poly1305_blocks(struct poly1305_desc_ctx *dctx, const u8 *src,
>> {
>> if (unlikely(!dctx->sset)) {
>> if (!dctx->rset) {
>> - poly1305_init_arch(dctx, src);
>> + poly1305_init_arm64(&dctx->h, src);
>> src += POLY1305_BLOCK_SIZE;
>> len -= POLY1305_BLOCK_SIZE;
>> dctx->rset = 1;
>
> With this change, we no longer initialise dctx->buflen to 0 as part of the
> initialisation. Looking at neon_poly1305_do_update(), I'm a bit worried
> that we could land in the 'if (likely(len >= POLY1305_BLOCK_SIZE))' block,
> end up with len == 0 and fail to set dctx->buflen. Is this a problem, or is
> my ignorance showing?
>
> Will
> .
Thanks Will.
I noticed this as well, but I leaved it out so that the behavior is the
same as the implementation for arm. The buflen here seems to be used for
maintaining any excessive data after the last block, and is zeroed
during init. I am not sure why it should be zeroed again during key
initialization. Maybe the thought was that the very first block of the
data is always used for initializing rset and that is also considered to
be the "initialization" process for the algorithm, thus the zeroing of
buflen. I could be completely wrong though.
--
Best
GUO Zihua
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-07-20 9:58 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) [this message]
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
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=a29cb083-0305-3467-976c-e541daefc5e8@huawei.com \
--to=guozihua@huawei.com \
--cc=catalin.marinas@arm.com \
--cc=davem@davemloft.net \
--cc=ebiggers@kernel.org \
--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