mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] pkcs7: Check all signers before waiving authattrs rejection
@ 2026-08-22 21:27 Jérémy Jean
  2026-09-23  8:46 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Jérémy Jean @ 2026-08-22 21:27 UTC (permalink / raw)
  To: dhowells, lukas, ignat, herbert, davem
  Cc: keyrings, linux-crypto, linux-modules, linux-kernel,
	Jérémy Jean

pkcs7_check_authattrs() only looks at the first SignerInfo when deciding
whether rejection of authenticated attributes may be waived.  For the
remaining signers it checks only that authenticated attributes are either
present on all signers or absent from all of them.

This means an unmatched ML-DSA signer can be placed first, followed by a
trusted RSA, ECDSA, or ECRDSA signer.  Verification skips the unmatched
signature and accepts the later trusted signer.  The first signer still
leaves the waiver enabled for the whole message, so the non-ML-DSA signer
can use an exception intended only for ML-DSA.

Check each SignerInfo's public-key algorithm before leaving the waiver
enabled.

Fixes: 91db696adea4 ("pkcs7: Allow authenticatedAttributes for ML-DSA")
Assisted-by: Codex:gpt-5
Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
---
 crypto/asymmetric_keys/pkcs7_parser.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/crypto/asymmetric_keys/pkcs7_parser.c b/crypto/asymmetric_keys/pkcs7_parser.c
index 6e3ffda..7f00e45 100644
--- a/crypto/asymmetric_keys/pkcs7_parser.c
+++ b/crypto/asymmetric_keys/pkcs7_parser.c
@@ -111,6 +111,12 @@ static int pkcs7_check_authattrs(struct pkcs7_message *msg)
 		if (!!sinfo->authattrs != want)
 			goto inconsistent;
 
+#ifdef CONFIG_PKCS7_WAIVE_AUTHATTRS_REJECTION_FOR_MLDSA
+		if (sinfo->authattrs &&
+		    strncmp(sinfo->sig->pkey_algo, "mldsa", 5) != 0)
+			msg->authattrs_rej_waivable = false;
+#endif
+
 		if (!sinfo->authattrs &&
 		    sinfo->sig->algo_takes_data)
 			sinfo->sig->hash_algo = "none";
-- 
2.47.3


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

* Re: [PATCH] pkcs7: Check all signers before waiving authattrs rejection
  2026-08-22 21:27 [PATCH] pkcs7: Check all signers before waiving authattrs rejection Jérémy Jean
@ 2026-09-23  8:46 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2026-09-23  8:46 UTC (permalink / raw)
  To: Jérémy Jean
  Cc: dhowells, lukas, ignat, davem, keyrings, linux-crypto,
	linux-modules, linux-kernel

On Sat, Aug 22, 2026 at 09:27:04PM +0000, Jérémy Jean wrote:
> pkcs7_check_authattrs() only looks at the first SignerInfo when deciding
> whether rejection of authenticated attributes may be waived.  For the
> remaining signers it checks only that authenticated attributes are either
> present on all signers or absent from all of them.
> 
> This means an unmatched ML-DSA signer can be placed first, followed by a
> trusted RSA, ECDSA, or ECRDSA signer.  Verification skips the unmatched
> signature and accepts the later trusted signer.  The first signer still
> leaves the waiver enabled for the whole message, so the non-ML-DSA signer
> can use an exception intended only for ML-DSA.
> 
> Check each SignerInfo's public-key algorithm before leaving the waiver
> enabled.
> 
> Fixes: 91db696adea4 ("pkcs7: Allow authenticatedAttributes for ML-DSA")
> Assisted-by: Codex:gpt-5
> Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
> ---
>  crypto/asymmetric_keys/pkcs7_parser.c | 6 ++++++
>  1 file changed, 6 insertions(+)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

end of thread, other threads:[~2026-09-23  8:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-22 21:27 [PATCH] pkcs7: Check all signers before waiving authattrs rejection Jérémy Jean
2026-09-23  8:46 ` Herbert Xu

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®