From: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
To: "Jérémy Jean" <Jeremy.Jean@oss.cyber.gouv.fr>
Cc: Lukas Wunner <lukas@wunner.de>, Ignat Korchagin <ignat@linux.win>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] crypto: rsassa-pkcs1: reject undersized keys when signing
Date: Wed, 26 Aug 2026 21:14:04 +0530 [thread overview]
Message-ID: <A894B32E-FF69-4459-BB5E-662E4BEEA9F8@linux.ibm.com> (raw)
In-Reply-To: <20260826103744.1554131-2-Jeremy.Jean@oss.cyber.gouv.fr>
> On 26 Aug 2026, at 4:07 PM, Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr> wrote:
>
> rsassa_pkcs1_sign() subtracts 11 from the unsigned key size before
> checking that the key is large enough for PKCS#1 v1.5 padding:
>
> if (slen + hash_prefix->size > ctx->key_size - 11)
> return -EOVERFLOW;
>
> If the RSA modulus is shorter than 11 bytes, the subtraction wraps.
> With a one-byte key and hash=none, the padding memset() writes past
> the output buffer.
>
> KASAN reports:
>
> BUG: KASAN: slab-out-of-bounds in rsassa_pkcs1_sign+0x1ad/0x3b0
> Write of size 4294967294 at addr ...
> The buggy address is located 0 bytes to the right of
> allocated 1-byte region [...]
>
> Reject keys shorter than the minimum encoded message size.
>
> Fixes: 3d5b1ecdea6f ("crypto: rsa - RSA padding algorithm")
> Assisted-by: Codex:gpt-5
> Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
Reviewed-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
Thanks,
Sudhakar
> ---
> crypto/rsassa-pkcs1.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/crypto/rsassa-pkcs1.c b/crypto/rsassa-pkcs1.c
> index 94fa5e9600e7..d0e4a885397f 100644
> --- a/crypto/rsassa-pkcs1.c
> +++ b/crypto/rsassa-pkcs1.c
> @@ -169,7 +169,7 @@ static int rsassa_pkcs1_sign(struct crypto_sig *tfm,
> u8 *in_buf;
> int err;
>
> - if (!ctx->key_size)
> + if (ctx->key_size < 11)
> return -EINVAL;
>
> if (dlen < ctx->key_size)
> --
> 2.47.3
>
>
next prev parent reply other threads:[~2026-08-26 15:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 10:37 [PATCH 0/2] crypto: rsassa-pkcs1: fix undersized key handling Jérémy Jean
2026-08-26 10:37 ` [PATCH 1/2] crypto: rsassa-pkcs1: reject undersized keys when signing Jérémy Jean
2026-08-26 15:44 ` Sudhakar Kuppusamy [this message]
2026-08-26 10:37 ` [PATCH 2/2] crypto: rsassa-pkcs1: reject undersized keys when verifying Jérémy Jean
2026-08-26 15:44 ` Sudhakar Kuppusamy
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=A894B32E-FF69-4459-BB5E-662E4BEEA9F8@linux.ibm.com \
--to=sudhakar@linux.ibm.com \
--cc=Jeremy.Jean@oss.cyber.gouv.fr \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=ignat@linux.win \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas@wunner.de \
/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