From: Dan Carpenter <dan@pereq.eu>
To: Andrew Morton <akpm@linux-foundation.org>,
Herbert Xu <herbert@gondor.apana.org.au>,
Nicolai Stange <nicstange@gmail.com>,
Mimi Zohar <zohar@us.ibm.com>,
Dmitry Kasatkin <dmitry.kasatkin@intel.com>
Cc: "Karthik Bhargavan" <karthik@pereq.eu>,
"Clément Blaudeau" <clement@cryspen.com>,
linux-kernel@vger.kernel.org, "Dan Carpenter" <dan@pereq.eu>
Subject: [PATCH 3/3] lib/digsig: Reject garbage bytes after the signature
Date: Wed, 02 Dec 2026 15:20:30 +0300 [thread overview]
Message-ID: <20261202-digsig_send-v1-3-2797f094dac3@pereq.eu> (raw)
In-Reply-To: <20261202-digsig_send-v1-0-2797f094dac3@pereq.eu>
The digsig_verify_rsa() function accepts signatures with garbage after
the end. Reject signatures that aren't the correct length.
evmctl writes the header, the bit count and the RSA output and
nothing else, so no one is affected by this in real life. It's just a
correctness issue.
Fixes: 051dbb918c7f ("crypto: digital signature verification support")
Signed-off-by: Dan Carpenter <dan@pereq.eu>
---
lib/digsig.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/lib/digsig.c b/lib/digsig.c
index 4940ce755750..18683e774bbd 100644
--- a/lib/digsig.c
+++ b/lib/digsig.c
@@ -135,6 +135,11 @@ static int digsig_verify_rsa(struct key *key,
goto err;
}
+ if (nret != siglen) {
+ err = -EINVAL;
+ goto err;
+ }
+
if (mpi_cmp(in, pkey[0]) >= 0) {
err = -EINVAL;
goto err;
--
2.53.0
prev parent reply other threads:[~2026-12-02 12:20 UTC|newest]
Thread overview: 4+ 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-02 12:20 ` [PATCH 2/3] lib/digsig: Reject a signature larger than the modulus Dan Carpenter
2026-12-02 12:20 ` Dan Carpenter [this message]
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=20261202-digsig_send-v1-3-2797f094dac3@pereq.eu \
--to=dan@pereq.eu \
--cc=akpm@linux-foundation.org \
--cc=clement@cryspen.com \
--cc=dmitry.kasatkin@intel.com \
--cc=herbert@gondor.apana.org.au \
--cc=karthik@pereq.eu \
--cc=linux-kernel@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 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®