From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,zohar@us.ibm.com,nicstange@gmail.com,
karthik@pereq.eu,herbert@gondor.apana.org.au,ebiggers@kernel.org,
dmitry.kasatkin@gmail.com,clement@cryspen.com,dan@pereq.eu,
akpm@linux-foundation.org
Subject: + lib-digsig-reject-a-signature-larger-than-the-modulus.patch added to mm-nonmm-unstable branch
Date: Thu, 03 Dec 2026 11:37:12 -0800 [thread overview]
Message-ID: <20261203193712.CED321F000C2@smtp.kernel.org> (raw)
In-Reply-To: <20261202-digsig_send-v1-2-2797f094dac3@pereq.eu>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3332 bytes --]
The patch titled
Subject: lib/digsig: reject a signature larger than the modulus
has been added to the -mm mm-nonmm-unstable branch. Its filename is
lib-digsig-reject-a-signature-larger-than-the-modulus.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/lib-digsig-reject-a-signature-larger-than-the-modulus.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: reject a signature larger than the modulus
Date: Wed, 02 Dec 2026 15:20:29 +0300
This is a correctness fix based on the RFC. Currently,
digsig_verify_rsa() accepts a legacy IMA or EVM signature even if the RSA
modulus has been added to it. That's a bug: it means one signature could
have several different encodings that verify.
RSA verification (RSAVP1 in RFC 8017 section 5.2.2) starts by checking
that the signature s is less than the modulus n. digsig_verify_rsa()
skips that check and computes s^e mod n directly, so s, s + n, s + 2n and
so on all give the same result. No signature is forged, but a different
value is accepted for the same file. The kernel's other RSA code rejects
s >= n in rsa_check_payload().
Reject a signature that is greater than or equal to the modulus.
In real life signatures made by evmctl are always less than n because
RSA_private_encrypt() returns m^d mod n. So it means no one is affected
by this bug in practice but also fixing it has no risk of breaking
anything.
Link: https://patch.msgid.link/20261202-digsig_send-v1-2-2797f094dac3@pereq.eu
Fixes: 051dbb918c7f ("crypto: digital signature verification support")
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>
lib/digsig.c | 5 +++++
1 file changed, 5 insertions(+)
--- a/lib/digsig.c~lib-digsig-reject-a-signature-larger-than-the-modulus
+++ a/lib/digsig.c
@@ -135,6 +135,11 @@ static int digsig_verify_rsa(struct key
goto err;
}
+ if (mpi_cmp(in, pkey[0]) >= 0) {
+ err = -EINVAL;
+ goto err;
+ }
+
res = mpi_alloc(mpi_get_nlimbs(in) * 2);
if (!res)
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
next prev parent reply other threads:[~2026-12-03 19:37 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
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 12:20 ` [PATCH 2/3] lib/digsig: Reject a signature larger than the modulus Dan Carpenter
2026-12-03 19:37 ` Andrew Morton [this message]
2026-12-02 12:20 ` [PATCH 3/3] lib/digsig: Reject garbage bytes after the signature Dan Carpenter
2026-12-03 19:37 ` + lib-digsig-reject-garbage-bytes-after-the-signature.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
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=20261203193712.CED321F000C2@smtp.kernel.org \
--to=akpm@linux-foundation.org \
--cc=clement@cryspen.com \
--cc=dan@pereq.eu \
--cc=dmitry.kasatkin@gmail.com \
--cc=ebiggers@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=karthik@pereq.eu \
--cc=mm-commits@vger.kernel.org \
--cc=nicstange@gmail.com \
--cc=zohar@us.ibm.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.