Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH 0/3] lib/digsig: fix some bugs in digsig
@ 2026-12-02 12:20 Dan Carpenter
  2026-12-02 12:20 ` [PATCH 1/3] lib/digsig: Fix error pointer dereference in digsig_verify_rsa() Dan Carpenter
  2026-12-02 20:57 ` [PATCH 0/3] lib/digsig: fix some bugs in digsig Andrew Morton
  0 siblings, 2 replies; 10+ messages in thread
From: Dan Carpenter @ 2026-12-02 12:20 UTC (permalink / raw)
  To: Andrew Morton, Herbert Xu, Nicolai Stange, Mimi Zohar,
	Dmitry Kasatkin
  Cc: Karthik Bhargavan, Clément Blaudeau, linux-kernel,
	Dan Carpenter, stable

Pereq is doing formal verification work.  These are some bugs we found.

* Dereferencing an error pointer on the error path
* Not implementing the RFC correctly
* Allowing garbage bytes after a signature

Fixing the last two bugs is just about correctness and they don't
actually affect real life.

Signed-off-by: Dan Carpenter <dan@pereq.eu>
---
Dan Carpenter (3):
      lib/digsig: Fix error pointer dereference in digsig_verify_rsa()
      lib/digsig: Reject a signature larger than the modulus
      lib/digsig: Reject garbage bytes after the signature

 lib/digsig.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
---
base-commit: a9c48428cbd8d96b26f92631d0db6f8519c5fcc5
change-id: 20261202-digsig_send-1d579b20c1d2

Best regards,
--  
Dan Carpenter <dan@pereq.eu>


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

* [PATCH 1/3] lib/digsig: Fix error pointer dereference in digsig_verify_rsa()
  2026-12-02 12:20 [PATCH 0/3] lib/digsig: fix some bugs in digsig Dan Carpenter
@ 2026-12-02 12:20 ` Dan Carpenter
  2026-12-03 19:37   ` + lib-digsig-fix-error-pointer-dereference-in-digsig_verify_rsa.patch added to mm-nonmm-unstable branch Andrew Morton
  2026-12-02 20:57 ` [PATCH 0/3] lib/digsig: fix some bugs in digsig Andrew Morton
  1 sibling, 1 reply; 10+ messages in thread
From: Dan Carpenter @ 2026-12-02 12:20 UTC (permalink / raw)
  To: Andrew Morton, Herbert Xu, Nicolai Stange, Mimi Zohar,
	Dmitry Kasatkin
  Cc: Karthik Bhargavan, Clément Blaudeau, linux-kernel,
	Dan Carpenter, stable

This error path calls mpi_free() with an error pointer which will
crash.  Set the "in" pointer to a NULL instead.

Fixes: 03cdfaad491e ("lib/mpi: mpi_read_from_buffer(): return error code")
Cc: stable@vger.kernel.org
Signed-off-by: Dan Carpenter <dan@pereq.eu>
---
 lib/digsig.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/digsig.c b/lib/digsig.c
index 9dd319c12c7d..8ca6af0a8fd4 100644
--- a/lib/digsig.c
+++ b/lib/digsig.c
@@ -131,6 +131,7 @@ static int digsig_verify_rsa(struct key *key,
 	in = mpi_read_from_buffer(sig, &nret);
 	if (IS_ERR(in)) {
 		err = PTR_ERR(in);
+		in = NULL;
 		goto err;
 	}
 

-- 
2.53.0


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

* Re: [PATCH 0/3] lib/digsig: fix some bugs in digsig
  2026-12-02 12:20 [PATCH 0/3] lib/digsig: fix some bugs in digsig Dan Carpenter
  2026-12-02 12:20 ` [PATCH 1/3] lib/digsig: Fix error pointer dereference in digsig_verify_rsa() Dan Carpenter
@ 2026-12-02 20:57 ` Andrew Morton
  2026-12-03  6:18   ` Dan Carpenter
  1 sibling, 1 reply; 10+ messages in thread
From: Andrew Morton @ 2026-12-02 20:57 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Herbert Xu, Nicolai Stange, Mimi Zohar, Dmitry Kasatkin,
	Karthik Bhargavan, Clément Blaudeau, linux-kernel, stable,
	Dmitry Kasatkin

On Wed, 02 Dec 2026 15:20:27 +0300 Dan Carpenter <dan@pereq.eu> wrote:

> Pereq is doing formal verification work.  These are some bugs we found.
> 
> * Dereferencing an error pointer on the error path
> * Not implementing the RFC correctly
> * Allowing garbage bytes after a signature
> 
> Fixing the last two bugs is just about correctness and they don't
> actually affect real life.
> 
>  lib/digsig.c | 11 +++++++++++

Thanks.

hp2:/usr/src/mm> scripts/get_maintainer.pl -f lib/digsig.c 
Andrew Morton <akpm@linux-foundation.org> (maintainer:LIBRARY CODE)
linux-kernel@vger.kernel.org (open list:LIBRARY CODE)
LIBRARY CODE status: Supported
hp2:/usr/src/mm> 

Someone please change this!!

Also, Dmitry wrote this in 2011 and may no longer be @intel.com.  Let's
add his gmail.com identity.


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

* Re: [PATCH 0/3] lib/digsig: fix some bugs in digsig
  2026-12-02 20:57 ` [PATCH 0/3] lib/digsig: fix some bugs in digsig Andrew Morton
@ 2026-12-03  6:18   ` Dan Carpenter
  2026-12-03  6:44     ` Eric Biggers
  0 siblings, 1 reply; 10+ messages in thread
From: Dan Carpenter @ 2026-12-03  6:18 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Herbert Xu, Nicolai Stange, Mimi Zohar, Eric Biggers,
	Karthik Bhargavan, Clément Blaudeau, linux-kernel, stable,
	Dmitry Kasatkin

On Wed, Dec 02, 2026 at 12:57:16PM -0800, Andrew Morton wrote:
> On Wed, 02 Dec 2026 15:20:27 +0300 Dan Carpenter <dan@pereq.eu> wrote:
> 
> > Pereq is doing formal verification work.  These are some bugs we found.
> > 
> > * Dereferencing an error pointer on the error path
> > * Not implementing the RFC correctly
> > * Allowing garbage bytes after a signature
> > 
> > Fixing the last two bugs is just about correctness and they don't
> > actually affect real life.
> > 
> >  lib/digsig.c | 11 +++++++++++
> 
> Thanks.
> 
> hp2:/usr/src/mm> scripts/get_maintainer.pl -f lib/digsig.c 
> Andrew Morton <akpm@linux-foundation.org> (maintainer:LIBRARY CODE)
> linux-kernel@vger.kernel.org (open list:LIBRARY CODE)
> LIBRARY CODE status: Supported
> hp2:/usr/src/mm> 
> 
> Someone please change this!!

Someone needs to summon Greg.  Say his name three times.  :P

Realistically, it's probably going to fall to Mimi or maybe we could put
it under crypto?

regards,
dan carpenter

> 
> Also, Dmitry wrote this in 2011 and may no longer be @intel.com.  Let's
> add his gmail.com identity.

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

* Re: [PATCH 0/3] lib/digsig: fix some bugs in digsig
  2026-12-03  6:18   ` Dan Carpenter
@ 2026-12-03  6:44     ` Eric Biggers
  2026-12-03 12:09       ` Mimi Zohar
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Biggers @ 2026-12-03  6:44 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Andrew Morton, Herbert Xu, Nicolai Stange, Mimi Zohar,
	Karthik Bhargavan, Clément Blaudeau, linux-kernel, stable,
	linux-crypto, linux-integrity, Roberto Sassu, Dmitry Kasatkin

[ +Cc linux-crypto@vger.kernel.org and linux-integrity@vger.kernel.org ]

On Thu, Dec 03, 2026 at 09:18:53AM +0300, Dan Carpenter wrote:
> On Wed, Dec 02, 2026 at 12:57:16PM -0800, Andrew Morton wrote:
> > On Wed, 02 Dec 2026 15:20:27 +0300 Dan Carpenter <dan@pereq.eu> wrote:
> > 
> > > Pereq is doing formal verification work.  These are some bugs we found.
> > > 
> > > * Dereferencing an error pointer on the error path
> > > * Not implementing the RFC correctly
> > > * Allowing garbage bytes after a signature
> > > 
> > > Fixing the last two bugs is just about correctness and they don't
> > > actually affect real life.
> > > 
> > >  lib/digsig.c | 11 +++++++++++
> > 
> > Thanks.
> > 
> > hp2:/usr/src/mm> scripts/get_maintainer.pl -f lib/digsig.c 
> > Andrew Morton <akpm@linux-foundation.org> (maintainer:LIBRARY CODE)
> > linux-kernel@vger.kernel.org (open list:LIBRARY CODE)
> > LIBRARY CODE status: Supported
> > hp2:/usr/src/mm> 
> > 
> > Someone please change this!!
> 
> Someone needs to summon Greg.  Say his name three times.  :P
> 
> Realistically, it's probably going to fall to Mimi or maybe we could put
> it under crypto?
> 
> regards,
> dan carpenter

lib/crypto/ is for standalone cryptographic algorithm implementations.

lib/digsig.c is a high-level keyring consumer (using the keyrings
subsystem, which lib/crypto/ has no dependency on) that implements
support for the IMA/EVM-specific obsolete v1 IMA/EVM signature format,
hardcodes SHA-1 hashing, and uses a bespoke implementation of RSA PKCS#1
v1.5 on top of the MPI library.  Only that last part is a cryptographic
algorithm implementation (of an obsolete algorithm, of course).

I think it should be moved to be alongside its only caller in
security/integrity/ and renamed to digsig_v1.c.  That would make it be
owned by "INTEGRITY MEASUREMENT ARCHITECTURE" in MAINTAINERS.  Likewise,
include/linux/digsig.h should be a local header in security/integrity/.
Documentation/security/digsig.rst should just be deleted, I think.

Mimi, Roberto, Dmitry: does that sound good to you?

Note: at some point I'd like to fix the kernel's RSA code, in which case
digsig_v1.c would have something better to call than the MPI library.
But security/integrity/ is still the right place for this file.

- Eric

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

* RE: [PATCH 0/3] lib/digsig: fix some bugs in digsig
  2026-12-03  6:44     ` Eric Biggers
@ 2026-12-03 12:09       ` Mimi Zohar
  2026-12-03 13:49         ` Dmitry Kasatkin
  2026-12-03 18:45         ` Eric Biggers
  0 siblings, 2 replies; 10+ messages in thread
From: Mimi Zohar @ 2026-12-03 12:09 UTC (permalink / raw)
  To: Eric Biggers, Dan Carpenter
  Cc: Andrew Morton, Herbert Xu, Nicolai Stange, Karthik Bhargavan,
	Clément Blaudeau, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, linux-crypto@vger.kernel.org,
	linux-integrity@vger.kernel.org, Roberto Sassu, Dmitry Kasatkin

On Wed, 2026-12-02 at 22:44 -0800, Eric Biggers wrote:
> [ +Cc linux-crypto@vger.kernel.org and linux-integrity@vger.kernel.org ]
> 
> On Thu, Dec 03, 2026 at 09:18:53AM +0300, Dan Carpenter wrote:
> > On Wed, Dec 02, 2026 at 12:57:16PM -0800, Andrew Morton wrote:
> > > On Wed, 02 Dec 2026 15:20:27 +0300 Dan Carpenter <dan@pereq.eu> wrote:
> > > 
> > > > Pereq is doing formal verification work.  These are some bugs we found.
> > > > 
> > > > * Dereferencing an error pointer on the error path
> > > > * Not implementing the RFC correctly
> > > > * Allowing garbage bytes after a signature
> > > > 
> > > > Fixing the last two bugs is just about correctness and they don't
> > > > actually affect real life.
> > > > 
> > > >  lib/digsig.c | 11 +++++++++++
> > > 
> > > Thanks.
> > > 
> > > hp2:/usr/src/mm> scripts/get_maintainer.pl -f lib/digsig.c 
> > > Andrew Morton <akpm@linux-foundation.org> (maintainer:LIBRARY CODE)
> > > linux-kernel@vger.kernel.org (open list:LIBRARY CODE)
> > > LIBRARY CODE status: Supported
> > > hp2:/usr/src/mm> 
> > > 
> > > Someone please change this!!
> > 
> > Someone needs to summon Greg.  Say his name three times.  :P
> > 
> > Realistically, it's probably going to fall to Mimi or maybe we could put
> > it under crypto?
> > 
> > regards,
> > dan carpenter
> 
> lib/crypto/ is for standalone cryptographic algorithm implementations.
> 
> lib/digsig.c is a high-level keyring consumer (using the keyrings
> subsystem, which lib/crypto/ has no dependency on) that implements
> support for the IMA/EVM-specific obsolete v1 IMA/EVM signature format,
> hardcodes SHA-1 hashing, and uses a bespoke implementation of RSA PKCS#1
> v1.5 on top of the MPI library.  Only that last part is a cryptographic
> algorithm implementation (of an obsolete algorithm, of course).
> 
> I think it should be moved to be alongside its only caller in
> security/integrity/ and renamed to digsig_v1.c.  That would make it be
> owned by "INTEGRITY MEASUREMENT ARCHITECTURE" in MAINTAINERS.  Likewise,
> include/linux/digsig.h should be a local header in security/integrity/.
> Documentation/security/digsig.rst should just be deleted, I think.
> 
> Mimi, Roberto, Dmitry: does that sound good to you?
> 
> Note: at some point I'd like to fix the kernel's RSA code, in which case
> digsig_v1.c would have something better to call than the MPI library.
> But security/integrity/ is still the right place for this file.
> 

Thanks, Dan, Eric.

Eric, that sounds fine. At some point, the original IMA v1 signature format
should be deprecated and removed. It played an important role at the time, but
was replaced relatively quickly with sigv2 to support other hash algorithms.

Would you be willing to review Dan's fixes?

Mimi

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

* Re: [PATCH 0/3] lib/digsig: fix some bugs in digsig
  2026-12-03 12:09       ` Mimi Zohar
@ 2026-12-03 13:49         ` Dmitry Kasatkin
  2026-12-03 18:45         ` Eric Biggers
  1 sibling, 0 replies; 10+ messages in thread
From: Dmitry Kasatkin @ 2026-12-03 13:49 UTC (permalink / raw)
  To: Mimi Zohar
  Cc: Eric Biggers, Dan Carpenter, Andrew Morton, Herbert Xu,
	Nicolai Stange, Karthik Bhargavan, Clément Blaudeau,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	linux-crypto@vger.kernel.org, linux-integrity@vger.kernel.org,
	Roberto Sassu

On Thu, 3 Dec 2026 at 14:09, Mimi Zohar <zohar@us.ibm.com> wrote:
>
> On Wed, 2026-12-02 at 22:44 -0800, Eric Biggers wrote:
> > [ +Cc linux-crypto@vger.kernel.org and linux-integrity@vger.kernel.org ]
> >
> > On Thu, Dec 03, 2026 at 09:18:53AM +0300, Dan Carpenter wrote:
> > > On Wed, Dec 02, 2026 at 12:57:16PM -0800, Andrew Morton wrote:
> > > > On Wed, 02 Dec 2026 15:20:27 +0300 Dan Carpenter <dan@pereq.eu> wrote:
> > > >
> > > > > Pereq is doing formal verification work.  These are some bugs we found.
> > > > >
> > > > > * Dereferencing an error pointer on the error path
> > > > > * Not implementing the RFC correctly
> > > > > * Allowing garbage bytes after a signature
> > > > >
> > > > > Fixing the last two bugs is just about correctness and they don't
> > > > > actually affect real life.
> > > > >
> > > > >  lib/digsig.c | 11 +++++++++++
> > > >
> > > > Thanks.
> > > >
> > > > hp2:/usr/src/mm> scripts/get_maintainer.pl -f lib/digsig.c
> > > > Andrew Morton <akpm@linux-foundation.org> (maintainer:LIBRARY CODE)
> > > > linux-kernel@vger.kernel.org (open list:LIBRARY CODE)
> > > > LIBRARY CODE status: Supported
> > > > hp2:/usr/src/mm>
> > > >
> > > > Someone please change this!!
> > >
> > > Someone needs to summon Greg.  Say his name three times.  :P
> > >
> > > Realistically, it's probably going to fall to Mimi or maybe we could put
> > > it under crypto?
> > >
> > > regards,
> > > dan carpenter
> >
> > lib/crypto/ is for standalone cryptographic algorithm implementations.
> >
> > lib/digsig.c is a high-level keyring consumer (using the keyrings
> > subsystem, which lib/crypto/ has no dependency on) that implements
> > support for the IMA/EVM-specific obsolete v1 IMA/EVM signature format,
> > hardcodes SHA-1 hashing, and uses a bespoke implementation of RSA PKCS#1
> > v1.5 on top of the MPI library.  Only that last part is a cryptographic
> > algorithm implementation (of an obsolete algorithm, of course).
> >
> > I think it should be moved to be alongside its only caller in
> > security/integrity/ and renamed to digsig_v1.c.  That would make it be
> > owned by "INTEGRITY MEASUREMENT ARCHITECTURE" in MAINTAINERS.  Likewise,
> > include/linux/digsig.h should be a local header in security/integrity/.
> > Documentation/security/digsig.rst should just be deleted, I think.
> >
> > Mimi, Roberto, Dmitry: does that sound good to you?
> >

Hi,

Sounds like a good plan to remove it...

- Dmitry

> > Note: at some point I'd like to fix the kernel's RSA code, in which case
> > digsig_v1.c would have something better to call than the MPI library.
> > But security/integrity/ is still the right place for this file.
> >
>
> Thanks, Dan, Eric.
>
> Eric, that sounds fine. At some point, the original IMA v1 signature format
> should be deprecated and removed. It played an important role at the time, but
> was replaced relatively quickly with sigv2 to support other hash algorithms.
>
> Would you be willing to review Dan's fixes?
>
> Mimi

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

* Re: [PATCH 0/3] lib/digsig: fix some bugs in digsig
  2026-12-03 12:09       ` Mimi Zohar
  2026-12-03 13:49         ` Dmitry Kasatkin
@ 2026-12-03 18:45         ` Eric Biggers
  2026-12-03 19:36           ` Andrew Morton
  1 sibling, 1 reply; 10+ messages in thread
From: Eric Biggers @ 2026-12-03 18:45 UTC (permalink / raw)
  To: Mimi Zohar
  Cc: Dan Carpenter, Andrew Morton, Herbert Xu, Nicolai Stange,
	Karthik Bhargavan, Clément Blaudeau,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	linux-crypto@vger.kernel.org, linux-integrity@vger.kernel.org,
	Roberto Sassu, Dmitry Kasatkin

On Thu, Dec 03, 2026 at 12:09:49PM +0000, Mimi Zohar wrote:
> On Wed, 2026-12-02 at 22:44 -0800, Eric Biggers wrote:
> > [ +Cc linux-crypto@vger.kernel.org and linux-integrity@vger.kernel.org ]
> > 
> > On Thu, Dec 03, 2026 at 09:18:53AM +0300, Dan Carpenter wrote:
> > > On Wed, Dec 02, 2026 at 12:57:16PM -0800, Andrew Morton wrote:
> > > > On Wed, 02 Dec 2026 15:20:27 +0300 Dan Carpenter <dan@pereq.eu> wrote:
> > > > 
> > > > > Pereq is doing formal verification work.  These are some bugs we found.
> > > > > 
> > > > > * Dereferencing an error pointer on the error path
> > > > > * Not implementing the RFC correctly
> > > > > * Allowing garbage bytes after a signature
> > > > > 
> > > > > Fixing the last two bugs is just about correctness and they don't
> > > > > actually affect real life.
> > > > > 
> > > > >  lib/digsig.c | 11 +++++++++++
> > > > 
> > > > Thanks.
> > > > 
> > > > hp2:/usr/src/mm> scripts/get_maintainer.pl -f lib/digsig.c 
> > > > Andrew Morton <akpm@linux-foundation.org> (maintainer:LIBRARY CODE)
> > > > linux-kernel@vger.kernel.org (open list:LIBRARY CODE)
> > > > LIBRARY CODE status: Supported
> > > > hp2:/usr/src/mm> 
> > > > 
> > > > Someone please change this!!
> > > 
> > > Someone needs to summon Greg.  Say his name three times.  :P
> > > 
> > > Realistically, it's probably going to fall to Mimi or maybe we could put
> > > it under crypto?
> > > 
> > > regards,
> > > dan carpenter
> > 
> > lib/crypto/ is for standalone cryptographic algorithm implementations.
> > 
> > lib/digsig.c is a high-level keyring consumer (using the keyrings
> > subsystem, which lib/crypto/ has no dependency on) that implements
> > support for the IMA/EVM-specific obsolete v1 IMA/EVM signature format,
> > hardcodes SHA-1 hashing, and uses a bespoke implementation of RSA PKCS#1
> > v1.5 on top of the MPI library.  Only that last part is a cryptographic
> > algorithm implementation (of an obsolete algorithm, of course).
> > 
> > I think it should be moved to be alongside its only caller in
> > security/integrity/ and renamed to digsig_v1.c.  That would make it be
> > owned by "INTEGRITY MEASUREMENT ARCHITECTURE" in MAINTAINERS.  Likewise,
> > include/linux/digsig.h should be a local header in security/integrity/.
> > Documentation/security/digsig.rst should just be deleted, I think.
> > 
> > Mimi, Roberto, Dmitry: does that sound good to you?
> > 
> > Note: at some point I'd like to fix the kernel's RSA code, in which case
> > digsig_v1.c would have something better to call than the MPI library.
> > But security/integrity/ is still the right place for this file.
> > 
> 
> Thanks, Dan, Eric.
> 
> Eric, that sounds fine. At some point, the original IMA v1 signature format
> should be deprecated and removed. It played an important role at the time, but
> was replaced relatively quickly with sigv2 to support other hash algorithms.
> 
> Would you be willing to review Dan's fixes?
> 

For the series:

Reviewed-by: Eric Biggers <ebiggers@kernel.org>

- Eric

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

* Re: [PATCH 0/3] lib/digsig: fix some bugs in digsig
  2026-12-03 18:45         ` Eric Biggers
@ 2026-12-03 19:36           ` Andrew Morton
  0 siblings, 0 replies; 10+ messages in thread
From: Andrew Morton @ 2026-12-03 19:36 UTC (permalink / raw)
  To: Eric Biggers
  Cc: Mimi Zohar, Dan Carpenter, Herbert Xu, Nicolai Stange,
	Karthik Bhargavan, Clément Blaudeau,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	linux-crypto@vger.kernel.org, linux-integrity@vger.kernel.org,
	Roberto Sassu, Dmitry Kasatkin

On Thu, 3 Dec 2026 10:45:28 -0800 Eric Biggers <ebiggers@kernel.org> wrote:

> > Eric, that sounds fine. At some point, the original IMA v1 signature format
> > should be deprecated and removed. It played an important role at the time, but
> > was replaced relatively quickly with sigv2 to support other hash algorithms.
> > 
> > Would you be willing to review Dan's fixes?
> > 
> 
> For the series:
> 
> Reviewed-by: Eric Biggers <ebiggers@kernel.org>

Thanks.  I'll grab this series as presumably any new arrangements will
take a bit of setup.

As usual, if someone else merges this material I'll drop the mm.git
copy.

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

* + lib-digsig-fix-error-pointer-dereference-in-digsig_verify_rsa.patch added to mm-nonmm-unstable branch
  2026-12-02 12:20 ` [PATCH 1/3] lib/digsig: Fix error pointer dereference in digsig_verify_rsa() Dan Carpenter
@ 2026-12-03 19:37   ` Andrew Morton
  0 siblings, 0 replies; 10+ messages in thread
From: Andrew Morton @ 2026-12-03 19:37 UTC (permalink / raw)
  To: mm-commits, zohar, stable, nicstange, karthik, herbert, ebiggers,
	dmitry.kasatkin, clement, dan, akpm

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2994 bytes --]


The patch titled
     Subject: lib/digsig: fix error pointer dereference in digsig_verify_rsa()
has been added to the -mm mm-nonmm-unstable branch.  Its filename is
     lib-digsig-fix-error-pointer-dereference-in-digsig_verify_rsa.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/lib-digsig-fix-error-pointer-dereference-in-digsig_verify_rsa.patch

This patch will later appear in the mm-nonmm-unstable branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days

------------------------------------------------------
From: Dan Carpenter <dan@pereq.eu>
Subject: lib/digsig: fix error pointer dereference in digsig_verify_rsa()
Date: Wed, 02 Dec 2026 15:20:28 +0300

Patch series "lib/digsig: fix some bugs in digsig".

Pereq is doing formal verification work.  These are some bugs we found.

* Dereferencing an error pointer on the error path
* Not implementing the RFC correctly
* Allowing garbage bytes after a signature

Fixing the last two bugs is just about correctness and they don't
actually affect real life.


This patch (of 3):

This error path calls mpi_free() with an error pointer which will
crash.  Set the "in" pointer to a NULL instead.

Link: https://lore.kernel.org/20261202-digsig_send-v1-0-2797f094dac3@pereq.eu
Link: https://patch.msgid.link/20261202-digsig_send-v1-1-2797f094dac3@pereq.eu
Fixes: 03cdfaad491e ("lib/mpi: mpi_read_from_buffer(): return error code")
Signed-off-by: Dan Carpenter <dan@pereq.eu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Eric Biggers <ebiggers@kernel.org>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Nicolai Stange <nicstange@gmail.com>
Cc: Mimi Zohar <zohar@us.ibm.com>
Cc: Karthik Bhargavan <karthik@pereq.eu>
Cc: Clément Blaudeau <clement@cryspen.com>
Cc: Dmitry Kasatkin <dmitry.kasatkin@gmail.com>
Cc: <stable@vger.kernel.org>

 lib/digsig.c |    1 +
 1 file changed, 1 insertion(+)

--- a/lib/digsig.c~lib-digsig-fix-error-pointer-dereference-in-digsig_verify_rsa
+++ a/lib/digsig.c
@@ -131,6 +131,7 @@ static int digsig_verify_rsa(struct key
 	in = mpi_read_from_buffer(sig, &nret);
 	if (IS_ERR(in)) {
 		err = PTR_ERR(in);
+		in = NULL;
 		goto err;
 	}
 
_

Patches currently in -mm which might be from dan@pereq.eu are

lib-digsig-fix-error-pointer-dereference-in-digsig_verify_rsa.patch
lib-digsig-reject-a-signature-larger-than-the-modulus.patch
lib-digsig-reject-garbage-bytes-after-the-signature.patch


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

end of thread, other threads:[~2026-12-03 19:37 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 12:20 [PATCH 0/3] lib/digsig: fix some bugs in digsig Dan Carpenter
2026-12-02 12:20 ` [PATCH 1/3] lib/digsig: Fix error pointer dereference in digsig_verify_rsa() Dan Carpenter
2026-12-03 19:37   ` + lib-digsig-fix-error-pointer-dereference-in-digsig_verify_rsa.patch added to mm-nonmm-unstable branch Andrew Morton
2026-12-02 20:57 ` [PATCH 0/3] lib/digsig: fix some bugs in digsig Andrew Morton
2026-12-03  6:18   ` Dan Carpenter
2026-12-03  6:44     ` Eric Biggers
2026-12-03 12:09       ` Mimi Zohar
2026-12-03 13:49         ` Dmitry Kasatkin
2026-12-03 18:45         ` Eric Biggers
2026-12-03 19:36           ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox