From: "Tianchu Chen" <tianchu.chen@linux.dev>
To: sashiko-reviews@lists.linux.dev
Cc: linux-sunxi@lists.linux.dev
Subject: Re: [PATCH] crypto: sun4i-ss: restrict PRNG seed length to prevent heap overflow
Date: Fri, 29 May 2026 03:03:21 +0000 [thread overview]
Message-ID: <bae676bd29a955ceb6b224190904bbbab8a23a3a@linux.dev> (raw)
In-Reply-To: <20260528152939.0C45B1F000E9@smtp.kernel.org>
May 28, 2026 at 11:29 PM, sashiko-bot@kernel.org mailto:sashiko-bot@kernel.org wrote:
>
> Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
>
> New issues:
> - [Critical] The newly added bounds check unconditionally rejects valid seeds and completely breaks PRNG initialization on 64-bit architectures.
>
> Pre-existing issues:
> - [Critical] This problem wasn't introduced by this patch, but the PRNG generation function silently truncates unaligned requested lengths, failing to generate random bytes for the remainder of the buffer while still returning success.
> - [High] This problem wasn't introduced by this patch, but the patch silently permits undersized seeds, leading to partial seed updates.
> - [High] This problem wasn't introduced by this patch, but the PRNG seed is copied into the shared device state without any locking, creating a data race with concurrent PRNG generations.
> - [High] This problem wasn't introduced by this patch, but there is a blind read from TXFIFO in PRNG generation without checking if data is available.
> --
>
> commit ce68b95827dcfbd778d1a5a3d2de5fd10e821954
> Author: Tianchu Chen <flynnnchen@tencent.com>
> crypto: sun4i-ss: restrict PRNG seed length to prevent heap overflow
>
> This commit restricts the PRNG seed length in sun4i_ss_prng_seed() to prevent
> a heap overflow. Without bounds checking, user-supplied seeds via AF_ALG could
> exceed the fixed-size buffer and corrupt adjacent memory.
>
> Fixes: 6298e948215f ("crypto: sunxi-ss - Add Allwinner Security System crypto accelerator")
> Cc: stable@vger.kernel.org
>
> >
> > diff --git a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-prng.c b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-prng.c
> > index 491fcb7b81b40..010fa891c1056 100644
> > --- a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-prng.c
> > +++ b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-prng.c
> > @@ -8,6 +8,8 @@ int sun4i_ss_prng_seed(struct crypto_rng *tfm, const u8 *seed,
> > struct rng_alg *alg = crypto_rng_alg(tfm);
> >
> > algt = container_of(alg, struct sun4i_ss_alg_template, alg.rng);
> > + if (slen > sizeof(algt->ss->seed))
> > + return -EINVAL;
> >
> [Severity: Critical]
> Does sizeof(algt->ss->seed) unconditionally reject valid seeds?
>
> On 64-bit architectures, BITS_PER_LONG is 64, which makes the evaluation of
> SS_SEED_LEN / BITS_PER_LONG result in 3. The seed array becomes u32 seed[3],
> yielding a total size of 12 bytes. This would trigger the EINVAL branch for
> standard 24-byte seeds and completely break PRNG initialization.
>
sun4i-ss is designed for 32-bit ARM only (A10/A13/A20/A33). It's behind
ARCH_SUNXI in Kconfig so it never builds on 64-bit. On the real hardware
sizeof(ss->seed) is always 24, same as .seedsize.
next prev parent reply other threads:[~2026-05-29 3:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-28 14:53 [PATCH] crypto: sun4i-ss: restrict PRNG seed length to prevent heap overflow Tianchu Chen
2026-05-28 15:29 ` sashiko-bot
2026-05-29 3:03 ` Tianchu Chen [this message]
2026-05-29 6:11 ` Herbert Xu
2026-05-29 7:05 ` Tianchu Chen
2026-05-29 8:08 ` [PATCH v2] crypto: sun4i-ss - clamp " Tianchu Chen
2026-05-29 8:42 ` sashiko-bot
2026-05-29 16:10 ` Eric Biggers
2026-05-29 17:10 ` Corentin Labbe
2026-05-29 17:33 ` Eric Biggers
2026-05-29 19:41 ` Eric Biggers
2026-06-01 14:57 ` Corentin Labbe
2026-06-01 15:47 ` 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=bae676bd29a955ceb6b224190904bbbab8a23a3a@linux.dev \
--to=tianchu.chen@linux.dev \
--cc=linux-sunxi@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
/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