[PATCH 3/3] lib/digsig: Reject garbage bytes after the signature
From: Dan Carpenter
Date: Wed Dec 02 2026 - 07:21:01 EST
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@xxxxxxxx>
---
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