mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [REPOST PATCH] crypto: caam - reject overlong RSA CRT parameters
@ 2026-10-08  9:35 Jérémy Jean
  2026-10-15  9:28 ` Herbert Xu
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jérémy Jean @ 2026-10-08  9:35 UTC (permalink / raw)
  To: Horia Geantă,
	Pankaj Gupta, Sahil Malhotra, Herbert Xu, David S. Miller,
	linux-crypto, linux-kernel
  Cc: Jérémy Jean, stable

caam_read_rsa_crt() right-aligns dP, dQ, and qInv in buffers sized
from the corresponding prime. rsa_parse_priv_key() only bounds these
integers against n, so a malformed key can provide, for example, a
two-byte dP with a one-byte p. dstlen - nbytes then underflows and
memcpy() writes outside the allocation during set_priv_key(). KASAN
reports a slab-out-of-bounds write in caam_read_rsa_crt().

Reject empty or overlong CRT parameters after stripping leading zeros.
qInv is consumed by CAAM as a p-sized value, so size it from p rather
than q to match the DMA mapping in set_rsa_priv_f3_pdb(). Let the
top-level key cleanup handle partial form-3 allocations and return the
specific error to the caller.

Also test nbytes before dereferencing it while stripping zeros, so an
all-zero integer does not read one byte beyond its input.

Fixes: 4a651b122adb ("crypto: caam - add support for RSA key form 3")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
---
 drivers/crypto/caam/caampkc.c | 69 +++++++++++++++--------------------
 1 file changed, 30 insertions(+), 39 deletions(-)

diff --git a/drivers/crypto/caam/caampkc.c b/drivers/crypto/caam/caampkc.c
index cb001aa1de66..2082adaae585 100644
--- a/drivers/crypto/caam/caampkc.c
+++ b/drivers/crypto/caam/caampkc.c
@@ -880,7 +880,7 @@ static void caam_rsa_free_key(struct caam_rsa_key *key)
 
 static void caam_rsa_drop_leading_zeros(const u8 **ptr, size_t *nbytes)
 {
-	while (!**ptr && *nbytes) {
+	while (*nbytes && !**ptr) {
 		(*ptr)++;
 		(*nbytes)--;
 	}
@@ -896,22 +896,22 @@ static void caam_rsa_drop_leading_zeros(const u8 **ptr, size_t *nbytes)
  * @ptr   : pointer to {dP, dQ, qInv} CRT member
  * @nbytes: length in bytes of {dP, dQ, qInv} CRT member
  * @dstlen: length in bytes of corresponding p or q prime factor
+ * @dst   : pointer to the zero-padded output buffer
  */
-static u8 *caam_read_rsa_crt(const u8 *ptr, size_t nbytes, size_t dstlen)
+static int caam_read_rsa_crt(const u8 *ptr, size_t nbytes, size_t dstlen,
+			     u8 **dst)
 {
-	u8 *dst;
-
 	caam_rsa_drop_leading_zeros(&ptr, &nbytes);
-	if (!nbytes)
-		return NULL;
+	if (!nbytes || nbytes > dstlen)
+		return -EINVAL;
 
-	dst = kzalloc(dstlen, GFP_KERNEL);
-	if (!dst)
-		return NULL;
+	*dst = kzalloc(dstlen, GFP_KERNEL);
+	if (!*dst)
+		return -ENOMEM;
 
-	memcpy(dst + (dstlen - nbytes), ptr, nbytes);
+	memcpy(*dst + (dstlen - nbytes), ptr, nbytes);
 
-	return dst;
+	return 0;
 }
 
 /**
@@ -991,6 +991,7 @@ static int caam_rsa_set_priv_key_form(struct caam_rsa_ctx *ctx,
 	size_t p_sz = raw_key->p_sz;
 	size_t q_sz = raw_key->q_sz;
 	unsigned aligned_size;
+	int ret;
 
 	rsa_key->p = caam_read_raw_data(raw_key->p, &p_sz);
 	if (!rsa_key->p)
@@ -999,51 +1000,39 @@ static int caam_rsa_set_priv_key_form(struct caam_rsa_ctx *ctx,
 
 	rsa_key->q = caam_read_raw_data(raw_key->q, &q_sz);
 	if (!rsa_key->q)
-		goto free_p;
+		return -ENOMEM;
 	rsa_key->q_sz = q_sz;
 
 	aligned_size = ALIGN(raw_key->p_sz, dma_get_cache_alignment());
 	rsa_key->tmp1 = kzalloc(aligned_size, GFP_KERNEL);
 	if (!rsa_key->tmp1)
-		goto free_q;
+		return -ENOMEM;
 
 	aligned_size = ALIGN(raw_key->q_sz, dma_get_cache_alignment());
 	rsa_key->tmp2 = kzalloc(aligned_size, GFP_KERNEL);
 	if (!rsa_key->tmp2)
-		goto free_tmp1;
+		return -ENOMEM;
 
 	rsa_key->priv_form = FORM2;
 
-	rsa_key->dp = caam_read_rsa_crt(raw_key->dp, raw_key->dp_sz, p_sz);
-	if (!rsa_key->dp)
-		goto free_tmp2;
+	ret = caam_read_rsa_crt(raw_key->dp, raw_key->dp_sz, p_sz,
+				&rsa_key->dp);
+	if (ret)
+		return ret;
 
-	rsa_key->dq = caam_read_rsa_crt(raw_key->dq, raw_key->dq_sz, q_sz);
-	if (!rsa_key->dq)
-		goto free_dp;
+	ret = caam_read_rsa_crt(raw_key->dq, raw_key->dq_sz, q_sz,
+				&rsa_key->dq);
+	if (ret)
+		return ret;
 
-	rsa_key->qinv = caam_read_rsa_crt(raw_key->qinv, raw_key->qinv_sz,
-					  q_sz);
-	if (!rsa_key->qinv)
-		goto free_dq;
+	ret = caam_read_rsa_crt(raw_key->qinv, raw_key->qinv_sz, p_sz,
+				&rsa_key->qinv);
+	if (ret)
+		return ret;
 
 	rsa_key->priv_form = FORM3;
 
 	return 0;
-
-free_dq:
-	kfree_sensitive(rsa_key->dq);
-free_dp:
-	kfree_sensitive(rsa_key->dp);
-free_tmp2:
-	kfree_sensitive(rsa_key->tmp2);
-free_tmp1:
-	kfree_sensitive(rsa_key->tmp1);
-free_q:
-	kfree_sensitive(rsa_key->q);
-free_p:
-	kfree_sensitive(rsa_key->p);
-	return -ENOMEM;
 }
 
 static int caam_rsa_set_priv_key(struct crypto_akcipher *tfm, const void *key,
@@ -1061,6 +1050,8 @@ static int caam_rsa_set_priv_key(struct crypto_akcipher *tfm, const void *key,
 	if (ret)
 		return ret;
 
+	ret = -ENOMEM;
+
 	/* Copy key in DMA zone */
 	rsa_key->d = kmemdup(raw_key.d, raw_key.d_sz, GFP_KERNEL);
 	if (!rsa_key->d)
@@ -1097,7 +1088,7 @@ static int caam_rsa_set_priv_key(struct crypto_akcipher *tfm, const void *key,
 
 err:
 	caam_rsa_free_key(rsa_key);
-	return -ENOMEM;
+	return ret;
 }
 
 static unsigned int caam_rsa_max_size(struct crypto_akcipher *tfm)
-- 
2.47.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [REPOST PATCH] crypto: caam - reject overlong RSA CRT parameters
  2026-10-08  9:35 [REPOST PATCH] crypto: caam - reject overlong RSA CRT parameters Jérémy Jean
@ 2026-10-15  9:28 ` Herbert Xu
  2026-10-26  4:42   ` Herbert Xu
  2026-10-26 11:41 ` [EXT] " Sahil Malhotra (OSS)
  2026-11-04  9:04 ` Herbert Xu
  2 siblings, 1 reply; 6+ messages in thread
From: Herbert Xu @ 2026-10-15  9:28 UTC (permalink / raw)
  To: Jérémy Jean
  Cc: Horia Geantă,
	Pankaj Gupta, Sahil Malhotra, David S. Miller, linux-crypto,
	linux-kernel, stable

On Thu, Oct 08, 2026 at 09:35:53AM +0000, Jérémy Jean wrote:
> caam_read_rsa_crt() right-aligns dP, dQ, and qInv in buffers sized
> from the corresponding prime. rsa_parse_priv_key() only bounds these
> integers against n, so a malformed key can provide, for example, a
> two-byte dP with a one-byte p. dstlen - nbytes then underflows and
> memcpy() writes outside the allocation during set_priv_key(). KASAN
> reports a slab-out-of-bounds write in caam_read_rsa_crt().
> 
> Reject empty or overlong CRT parameters after stripping leading zeros.
> qInv is consumed by CAAM as a p-sized value, so size it from p rather
> than q to match the DMA mapping in set_rsa_priv_f3_pdb(). Let the
> top-level key cleanup handle partial form-3 allocations and return the
> specific error to the caller.
> 
> Also test nbytes before dereferencing it while stripping zeros, so an
> all-zero integer does not read one byte beyond its input.
> 
> Fixes: 4a651b122adb ("crypto: caam - add support for RSA key form 3")
> Cc: stable@vger.kernel.org
> Assisted-by: LLM
> Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
> ---
>  drivers/crypto/caam/caampkc.c | 69 +++++++++++++++--------------------
>  1 file changed, 30 insertions(+), 39 deletions(-)

Sahil, could you please review this patch?

Thanks,
-- 
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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [REPOST PATCH] crypto: caam - reject overlong RSA CRT parameters
  2026-10-15  9:28 ` Herbert Xu
@ 2026-10-26  4:42   ` Herbert Xu
  2026-10-26 11:42     ` [EXT] " Sahil Malhotra (OSS)
  0 siblings, 1 reply; 6+ messages in thread
From: Herbert Xu @ 2026-10-26  4:42 UTC (permalink / raw)
  To: Jérémy Jean
  Cc: Horia Geantă,
	Pankaj Gupta, Sahil Malhotra, David S. Miller, linux-crypto,
	linux-kernel, stable

On Thu, Oct 15, 2026 at 08:28:50PM +1100, Herbert Xu wrote:
> On Thu, Oct 08, 2026 at 09:35:53AM +0000, Jérémy Jean wrote:
> > caam_read_rsa_crt() right-aligns dP, dQ, and qInv in buffers sized
> > from the corresponding prime. rsa_parse_priv_key() only bounds these
> > integers against n, so a malformed key can provide, for example, a
> > two-byte dP with a one-byte p. dstlen - nbytes then underflows and
> > memcpy() writes outside the allocation during set_priv_key(). KASAN
> > reports a slab-out-of-bounds write in caam_read_rsa_crt().
> > 
> > Reject empty or overlong CRT parameters after stripping leading zeros.
> > qInv is consumed by CAAM as a p-sized value, so size it from p rather
> > than q to match the DMA mapping in set_rsa_priv_f3_pdb(). Let the
> > top-level key cleanup handle partial form-3 allocations and return the
> > specific error to the caller.
> > 
> > Also test nbytes before dereferencing it while stripping zeros, so an
> > all-zero integer does not read one byte beyond its input.
> > 
> > Fixes: 4a651b122adb ("crypto: caam - add support for RSA key form 3")
> > Cc: stable@vger.kernel.org
> > Assisted-by: LLM
> > Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
> > ---
> >  drivers/crypto/caam/caampkc.c | 69 +++++++++++++++--------------------
> >  1 file changed, 30 insertions(+), 39 deletions(-)
> 
> Sahil, could you please review this patch?

Hi Sahil:

It's been two weeks and you've provided no feedback.

If there isn't going to be timely feedback to patches on this
driver then it will be removed.

Thanks,
-- 
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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [EXT] [REPOST PATCH] crypto: caam - reject overlong RSA CRT parameters
  2026-10-08  9:35 [REPOST PATCH] crypto: caam - reject overlong RSA CRT parameters Jérémy Jean
  2026-10-15  9:28 ` Herbert Xu
@ 2026-10-26 11:41 ` Sahil Malhotra (OSS)
  2026-11-04  9:04 ` Herbert Xu
  2 siblings, 0 replies; 6+ messages in thread
From: Sahil Malhotra (OSS) @ 2026-10-26 11:41 UTC (permalink / raw)
  To: Jérémy Jean, Horia Geanta, Pankaj Gupta, Herbert Xu,
	David S. Miller, linux-crypto, linux-kernel
  Cc: stable

Hi Jeremy,

Sorry for the delayed response.

I am ok with this patch.
Reviewed-by: Sahil Malhotra <sahil.malhotra@nxp.com>

Regards,
Sahil Malhotra


NXP Confidential
> -----Original Message-----
> From: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
> Sent: 08 October 2026 15:06
> To: Horia Geanta <horia.geanta@nxp.com>; Pankaj Gupta
> <pankaj.gupta@nxp.com>; Sahil Malhotra <sahil.malhotra@nxp.com>;
> Herbert Xu <herbert@gondor.apana.org.au>; David S. Miller
> <davem@davemloft.net>; linux-crypto@vger.kernel.org; linux-
> kernel@vger.kernel.org
> Cc: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>; stable@vger.kernel.org
> Subject: [EXT] [REPOST PATCH] crypto: caam - reject overlong RSA CRT
> parameters
>
> Caution: This is an external email. Please take care when clicking links or
> opening attachments. When in doubt, report the message using the 'Report
> this email' button
>
>
> caam_read_rsa_crt() right-aligns dP, dQ, and qInv in buffers sized from the
> corresponding prime. rsa_parse_priv_key() only bounds these integers against
> n, so a malformed key can provide, for example, a two-byte dP with a one-
> byte p. dstlen - nbytes then underflows and
> memcpy() writes outside the allocation during set_priv_key(). KASAN reports
> a slab-out-of-bounds write in caam_read_rsa_crt().
>
> Reject empty or overlong CRT parameters after stripping leading zeros.
> qInv is consumed by CAAM as a p-sized value, so size it from p rather than q
> to match the DMA mapping in set_rsa_priv_f3_pdb(). Let the top-level key
> cleanup handle partial form-3 allocations and return the specific error to the
> caller.
>
> Also test nbytes before dereferencing it while stripping zeros, so an all-zero
> integer does not read one byte beyond its input.
>
> Fixes: 4a651b122adb ("crypto: caam - add support for RSA key form 3")
> Cc: stable@vger.kernel.org
> Assisted-by: LLM
> Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
> ---
>  drivers/crypto/caam/caampkc.c | 69 +++++++++++++++--------------------
>  1 file changed, 30 insertions(+), 39 deletions(-)
>
> diff --git a/drivers/crypto/caam/caampkc.c b/drivers/crypto/caam/caampkc.c
> index cb001aa1de66..2082adaae585 100644
> --- a/drivers/crypto/caam/caampkc.c
> +++ b/drivers/crypto/caam/caampkc.c
> @@ -880,7 +880,7 @@ static void caam_rsa_free_key(struct caam_rsa_key
> *key)
>
>  static void caam_rsa_drop_leading_zeros(const u8 **ptr, size_t *nbytes)  {
> -       while (!**ptr && *nbytes) {
> +       while (*nbytes && !**ptr) {
>                 (*ptr)++;
>                 (*nbytes)--;
>         }
> @@ -896,22 +896,22 @@ static void caam_rsa_drop_leading_zeros(const u8
> **ptr, size_t *nbytes)
>   * @ptr   : pointer to {dP, dQ, qInv} CRT member
>   * @nbytes: length in bytes of {dP, dQ, qInv} CRT member
>   * @dstlen: length in bytes of corresponding p or q prime factor
> + * @dst   : pointer to the zero-padded output buffer
>   */
> -static u8 *caam_read_rsa_crt(const u8 *ptr, size_t nbytes, size_t dstlen)
> +static int caam_read_rsa_crt(const u8 *ptr, size_t nbytes, size_t dstlen,
> +                            u8 **dst)
>  {
> -       u8 *dst;
> -
>         caam_rsa_drop_leading_zeros(&ptr, &nbytes);
> -       if (!nbytes)
> -               return NULL;
> +       if (!nbytes || nbytes > dstlen)
> +               return -EINVAL;
>
> -       dst = kzalloc(dstlen, GFP_KERNEL);
> -       if (!dst)
> -               return NULL;
> +       *dst = kzalloc(dstlen, GFP_KERNEL);
> +       if (!*dst)
> +               return -ENOMEM;
>
> -       memcpy(dst + (dstlen - nbytes), ptr, nbytes);
> +       memcpy(*dst + (dstlen - nbytes), ptr, nbytes);
>
> -       return dst;
> +       return 0;
>  }
>
>  /**
> @@ -991,6 +991,7 @@ static int caam_rsa_set_priv_key_form(struct
> caam_rsa_ctx *ctx,
>         size_t p_sz = raw_key->p_sz;
>         size_t q_sz = raw_key->q_sz;
>         unsigned aligned_size;
> +       int ret;
>
>         rsa_key->p = caam_read_raw_data(raw_key->p, &p_sz);
>         if (!rsa_key->p)
> @@ -999,51 +1000,39 @@ static int caam_rsa_set_priv_key_form(struct
> caam_rsa_ctx *ctx,
>
>         rsa_key->q = caam_read_raw_data(raw_key->q, &q_sz);
>         if (!rsa_key->q)
> -               goto free_p;
> +               return -ENOMEM;
>         rsa_key->q_sz = q_sz;
>
>         aligned_size = ALIGN(raw_key->p_sz, dma_get_cache_alignment());
>         rsa_key->tmp1 = kzalloc(aligned_size, GFP_KERNEL);
>         if (!rsa_key->tmp1)
> -               goto free_q;
> +               return -ENOMEM;
>
>         aligned_size = ALIGN(raw_key->q_sz, dma_get_cache_alignment());
>         rsa_key->tmp2 = kzalloc(aligned_size, GFP_KERNEL);
>         if (!rsa_key->tmp2)
> -               goto free_tmp1;
> +               return -ENOMEM;
>
>         rsa_key->priv_form = FORM2;
>
> -       rsa_key->dp = caam_read_rsa_crt(raw_key->dp, raw_key->dp_sz, p_sz);
> -       if (!rsa_key->dp)
> -               goto free_tmp2;
> +       ret = caam_read_rsa_crt(raw_key->dp, raw_key->dp_sz, p_sz,
> +                               &rsa_key->dp);
> +       if (ret)
> +               return ret;
>
> -       rsa_key->dq = caam_read_rsa_crt(raw_key->dq, raw_key->dq_sz, q_sz);
> -       if (!rsa_key->dq)
> -               goto free_dp;
> +       ret = caam_read_rsa_crt(raw_key->dq, raw_key->dq_sz, q_sz,
> +                               &rsa_key->dq);
> +       if (ret)
> +               return ret;
>
> -       rsa_key->qinv = caam_read_rsa_crt(raw_key->qinv, raw_key->qinv_sz,
> -                                         q_sz);
> -       if (!rsa_key->qinv)
> -               goto free_dq;
> +       ret = caam_read_rsa_crt(raw_key->qinv, raw_key->qinv_sz, p_sz,
> +                               &rsa_key->qinv);
> +       if (ret)
> +               return ret;
>
>         rsa_key->priv_form = FORM3;
>
>         return 0;
> -
> -free_dq:
> -       kfree_sensitive(rsa_key->dq);
> -free_dp:
> -       kfree_sensitive(rsa_key->dp);
> -free_tmp2:
> -       kfree_sensitive(rsa_key->tmp2);
> -free_tmp1:
> -       kfree_sensitive(rsa_key->tmp1);
> -free_q:
> -       kfree_sensitive(rsa_key->q);
> -free_p:
> -       kfree_sensitive(rsa_key->p);
> -       return -ENOMEM;
>  }
>
>  static int caam_rsa_set_priv_key(struct crypto_akcipher *tfm, const void *key,
> @@ -1061,6 +1050,8 @@ static int caam_rsa_set_priv_key(struct
> crypto_akcipher *tfm, const void *key,
>         if (ret)
>                 return ret;
>
> +       ret = -ENOMEM;
> +
>         /* Copy key in DMA zone */
>         rsa_key->d = kmemdup(raw_key.d, raw_key.d_sz, GFP_KERNEL);
>         if (!rsa_key->d)
> @@ -1097,7 +1088,7 @@ static int caam_rsa_set_priv_key(struct
> crypto_akcipher *tfm, const void *key,
>
>  err:
>         caam_rsa_free_key(rsa_key);
> -       return -ENOMEM;
> +       return ret;
>  }
>
>  static unsigned int caam_rsa_max_size(struct crypto_akcipher *tfm)
> --
> 2.47.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [EXT] Re: [REPOST PATCH] crypto: caam - reject overlong RSA CRT parameters
  2026-10-26  4:42   ` Herbert Xu
@ 2026-10-26 11:42     ` Sahil Malhotra (OSS)
  0 siblings, 0 replies; 6+ messages in thread
From: Sahil Malhotra (OSS) @ 2026-10-26 11:42 UTC (permalink / raw)
  To: Herbert Xu, Jérémy Jean
  Cc: Horia Geanta, Pankaj Gupta, David S. Miller, linux-crypto,
	linux-kernel, stable

Hi Herbert,

Sorry for the delay.
I just reviewed the patch and in process of reviewing other pending patches also.

Regards,
Sahil Malhotra


NXP Confidential
> -----Original Message-----
> From: Herbert Xu <herbert@gondor.apana.org.au>
> Sent: 26 October 2026 10:13
> To: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
> Cc: Horia Geanta <horia.geanta@nxp.com>; Pankaj Gupta
> <pankaj.gupta@nxp.com>; Sahil Malhotra <sahil.malhotra@nxp.com>; David
> S. Miller <davem@davemloft.net>; linux-crypto@vger.kernel.org; linux-
> kernel@vger.kernel.org; stable@vger.kernel.org
> Subject: [EXT] Re: [REPOST PATCH] crypto: caam - reject overlong RSA CRT
> parameters
>
> Caution: This is an external email. Please take care when clicking links
or
> opening attachments. When in doubt, report the message using the 'Report
> this email' button
>
>
> On Thu, Oct 15, 2026 at 08:28:50PM +1100, Herbert Xu wrote:
> > On Thu, Oct 08, 2026 at 09:35:53AM +0000, Jérémy Jean wrote:
> > > caam_read_rsa_crt() right-aligns dP, dQ, and qInv in buffers sized
> > > from the corresponding prime. rsa_parse_priv_key() only bounds these
> > > integers against n, so a malformed key can provide, for example, a
> > > two-byte dP with a one-byte p. dstlen - nbytes then underflows and
> > > memcpy() writes outside the allocation during set_priv_key(). KASAN
> > > reports a slab-out-of-bounds write in caam_read_rsa_crt().
> > >
> > > Reject empty or overlong CRT parameters after stripping leading zeros.
> > > qInv is consumed by CAAM as a p-sized value, so size it from p
> > > rather than q to match the DMA mapping in set_rsa_priv_f3_pdb(). Let
> > > the top-level key cleanup handle partial form-3 allocations and
> > > return the specific error to the caller.
> > >
> > > Also test nbytes before dereferencing it while stripping zeros, so
> > > an all-zero integer does not read one byte beyond its input.
> > >
> > > Fixes: 4a651b122adb ("crypto: caam - add support for RSA key form
> > > 3")
> > > Cc: stable@vger.kernel.org
> > > Assisted-by: LLM
> > > Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
> > > ---
> > >  drivers/crypto/caam/caampkc.c | 69
> > > +++++++++++++++--------------------
> > >  1 file changed, 30 insertions(+), 39 deletions(-)
> >
> > Sahil, could you please review this patch?
>
> Hi Sahil:
>
> It's been two weeks and you've provided no feedback.
>
> If there isn't going to be timely feedback to patches on this driver then
it will be
> removed.
>
> Thanks,
> --
> Email: Herbert Xu <herbert@gondor.apana.org.au> Home Page:
> https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgondo
> r.apana.org.au%2F~herbert%2F&data=05%7C02%7Csahil.malhotra%40nxp.c
> om%7C8ae2201e6d304d4bca0708df331b9897%7C686ea1d3bc2b4c6fa92c
> d99c5c301635%7C0%7C0%7C639285865952622472%7CUnknown%7CTW
> FpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXa
> W4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=YP2
> HDGxtmPHRqtU3%2F6lFqhjJwOUa8Czp6IV3QJI%2FaYc%3D&reserved=0
> PGP Key:
> https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgondo
> r.apana.org.au%2F~herbert%2Fpubkey.txt&data=05%7C02%7Csahil.malhotr
> a%40nxp.com%7C8ae2201e6d304d4bca0708df331b9897%7C686ea1d3bc
> 2b4c6fa92cd99c5c301635%7C0%7C0%7C639285865952656160%7CUnkn
> own%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwM
> CIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C
> &sdata=9N5IuUc0ReEfh37OUvvVqfWMs1NJRxS6yDd32NmUu84%3D&reser
> ved=0

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [REPOST PATCH] crypto: caam - reject overlong RSA CRT parameters
  2026-10-08  9:35 [REPOST PATCH] crypto: caam - reject overlong RSA CRT parameters Jérémy Jean
  2026-10-15  9:28 ` Herbert Xu
  2026-10-26 11:41 ` [EXT] " Sahil Malhotra (OSS)
@ 2026-11-04  9:04 ` Herbert Xu
  2 siblings, 0 replies; 6+ messages in thread
From: Herbert Xu @ 2026-11-04  9:04 UTC (permalink / raw)
  To: Jérémy Jean
  Cc: Horia Geantă,
	Pankaj Gupta, Sahil Malhotra, David S. Miller, linux-crypto,
	linux-kernel, stable

On Thu, Oct 08, 2026 at 09:35:53AM +0000, Jérémy Jean wrote:
> caam_read_rsa_crt() right-aligns dP, dQ, and qInv in buffers sized
> from the corresponding prime. rsa_parse_priv_key() only bounds these
> integers against n, so a malformed key can provide, for example, a
> two-byte dP with a one-byte p. dstlen - nbytes then underflows and
> memcpy() writes outside the allocation during set_priv_key(). KASAN
> reports a slab-out-of-bounds write in caam_read_rsa_crt().
> 
> Reject empty or overlong CRT parameters after stripping leading zeros.
> qInv is consumed by CAAM as a p-sized value, so size it from p rather
> than q to match the DMA mapping in set_rsa_priv_f3_pdb(). Let the
> top-level key cleanup handle partial form-3 allocations and return the
> specific error to the caller.
> 
> Also test nbytes before dereferencing it while stripping zeros, so an
> all-zero integer does not read one byte beyond its input.
> 
> Fixes: 4a651b122adb ("crypto: caam - add support for RSA key form 3")
> Cc: stable@vger.kernel.org
> Assisted-by: LLM
> Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
> ---
>  drivers/crypto/caam/caampkc.c | 69 +++++++++++++++--------------------
>  1 file changed, 30 insertions(+), 39 deletions(-)

Patch applied.  Thanks.
-- 
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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-04  9:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-08  9:35 [REPOST PATCH] crypto: caam - reject overlong RSA CRT parameters Jérémy Jean
2026-10-15  9:28 ` Herbert Xu
2026-10-26  4:42   ` Herbert Xu
2026-10-26 11:42     ` [EXT] " Sahil Malhotra (OSS)
2026-10-26 11:41 ` [EXT] " Sahil Malhotra (OSS)
2026-11-04  9:04 ` Herbert Xu

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®