From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796326633; b=CxGxBl45Nb6gd+TjwczLXGoIf7JJayXPsrdzKS8HgCVx5eUYaOa7P+RW9aCQQbmiqUzJ L+zxaQJV4aYuINbQwy6xJFr9JnJFdCDCU7EIGvm1i55584i5786LIihrmExaN/QPDVnjo 9AvlRwF5Bz5brrdxBuFCPvzb+RfhhhRWo6BjhjhCL/TZBbcZ5cvM7aLF111yYekeQD739 gdRKqStwyKxYnvdvqiBwAv43f8CznpO/AxOYqsRlRoVPNr20KT5OEBrxcqLVwIz4U4cB+ 2JLXcqrJe2+639VIHgS4Wgu+5bNGZk2eeTTFrnF/8B8LjwW6U7t44RnkMCbb1ohgSFg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796326633; h=Received:DKIM-Signature:Date:To:From:In-Reply-To:References:Subject: Message-Id; bh=63zHvTyybcg4sUQysxuuwCa5bkVg3R4luj/rwe1XXwc=; b=2Rup8ntGKHOobwJQFjXhjzqhjnv/7nr6C4udVEVTp3qww5fDaJ2+OJfZ+Tbb7IPxm0hv QHdyzL+fJOM2QP8lTWptXrpaopSmhN1sXtnFQTML/JhaXXdIUmmR9IEPsycoMFgUFX9Rs FfruCPcubPjmh2D3jizVylzjZzU4VELk35JqDf8uHysKqglUlmGb/qTb3Ve+z6HWa8fmX SPzRFhAMvWU1aLipzo5TY02NwIlP/zXIHbLfI4aJyen6RZHPk7sc+02EbpB+2+ghPIiFn mJNVP0/8VDF3Cv7+mVWLTVSuydVukJE7Lvo7oRPU1aob4q/3jJ4mn3Ih+qeZSnJr0WA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=ochYbE9H; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 47B6F60A3808 for ; Thu, 3 Dec 2026 19:37:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=ochYbE9H Received: by smtp.kernel.org (Postfix) with ESMTPSA id CED321F000C2; Thu, 3 Dec 2026 19:37:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796326632; bh=63zHvTyybcg4sUQysxuuwCa5bkVg3R4luj/rwe1XXwc=; h=Date:To:From:In-Reply-To:References:Subject; b=ochYbE9HK2b3T66AWE4WqA47TvQRAPgZcKkSRY4T1dPqqln23CpLvOrjytiP7Wy4P /J39uFSsyMkXcdoiO/asQMHqgOeYvZo3azUouFGxB+WFUUSzwo16tkMohYqNeQIvyY 5Y9IYbmm5pmm2PKFjyaWPA3NO9GGoKg142IBDZAg= Date: Thu, 03 Dec 2026 11:37:12 -0800 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 From: Andrew Morton In-Reply-To: <20261202-digsig_send-v1-2-2797f094dac3@pereq.eu> References: <20261202-digsig_send-v1-2-2797f094dac3@pereq.eu> Subject: + lib-digsig-reject-a-signature-larger-than-the-modulus.patch added to mm-nonmm-unstable branch Message-Id: <20261203193712.CED321F000C2@smtp.kernel.org> X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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 Signed-off-by: Andrew Morton Reviewed-by: Eric Biggers Cc: Herbert Xu Cc: Nicolai Stange Cc: Mimi Zohar Cc: Karthik Bhargavan Cc: Clément Blaudeau Cc: Dmitry Kasatkin 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