linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Fix bugs in public_key_verify_signature()
@ 2022-02-01  0:34 Eric Biggers
  2022-02-01  0:34 ` [PATCH 1/2] KEYS: asymmetric: enforce that sig algo matches key algo Eric Biggers
                   ` (4 more replies)
  0 siblings, 5 replies; 21+ messages in thread
From: Eric Biggers @ 2022-02-01  0:34 UTC (permalink / raw)
  To: keyrings, Jarkko Sakkinen, David Howells
  Cc: linux-crypto, linux-integrity, Stefan Berger, Gilad Ben-Yossef,
	Tianjia Zhang, Vitaly Chikunov, Mimi Zohar

This patchset fixes some bugs in public_key_verify_signature() where it
could be tricked into using the wrong algorithm, as was discussed at
https://lore.kernel.org/linux-integrity/20211202215507.298415-1-zohar@linux.ibm.com/T/#t

I'd appreciate it if the people who care about each of the supported
public key algorithms (RSA, ECDSA, ECRDSA, and SM2) would test this
patchset to make sure it still works for their use case(s).  I've tested
that X.509 and PKCS#7 with RSA still work.

Note, I have *not* included a fix for SM2 being implemented incorrectly.
That is another bug that I pointed out in the above thread.  I think
that bug is for the people who actually care about SM2.

This applies to v5.17-rc2.

Eric Biggers (2):
  KEYS: asymmetric: enforce that sig algo matches key algo
  KEYS: asymmetric: properly validate hash_algo and encoding

 crypto/asymmetric_keys/pkcs7_verify.c    |   6 --
 crypto/asymmetric_keys/public_key.c      | 126 ++++++++++++++++-------
 crypto/asymmetric_keys/x509_public_key.c |   6 --
 3 files changed, 91 insertions(+), 47 deletions(-)


base-commit: 26291c54e111ff6ba87a164d85d4a4e134b7315c
-- 
2.35.1


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

* [PATCH 1/2] KEYS: asymmetric: enforce that sig algo matches key algo
  2022-02-01  0:34 [PATCH 0/2] Fix bugs in public_key_verify_signature() Eric Biggers
@ 2022-02-01  0:34 ` Eric Biggers
  2022-02-02  2:52   ` Vitaly Chikunov
  2022-02-21  1:43   ` Jarkko Sakkinen
  2022-02-01  0:34 ` [PATCH 2/2] KEYS: asymmetric: properly validate hash_algo and encoding Eric Biggers
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 21+ messages in thread
From: Eric Biggers @ 2022-02-01  0:34 UTC (permalink / raw)
  To: keyrings, Jarkko Sakkinen, David Howells
  Cc: linux-crypto, linux-integrity, Stefan Berger, Gilad Ben-Yossef,
	Tianjia Zhang, Vitaly Chikunov, Mimi Zohar, stable

From: Eric Biggers <ebiggers@google.com>

Most callers of public_key_verify_signature(), including most indirect
callers via verify_signature() as well as pkcs7_verify_sig_chain(),
don't check that public_key_signature::pkey_algo matches
public_key::pkey_algo.  These should always match.  However, a malicious
signature could intentionally declare an unintended algorithm.  It is
essential that such signatures be rejected outright, or that the
algorithm of the *key* be used -- not the algorithm of the signature as
that would allow attackers to choose the algorithm used.

Currently, public_key_verify_signature() correctly uses the key's
algorithm when deciding which akcipher to allocate.  That's good.
However, it uses the signature's algorithm when deciding whether to do
the first step of SM2, which is incorrect.  Also, v4.19 and older
kernels used the signature's algorithm for the entire process.

Prevent such errors by making public_key_verify_signature() enforce that
the signature's algorithm matches the key's algorithm.

Also remove two checks of this done by callers, which are now redundant.

Cc: stable@vger.kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 crypto/asymmetric_keys/pkcs7_verify.c    |  6 ------
 crypto/asymmetric_keys/public_key.c      | 15 +++++++++++++++
 crypto/asymmetric_keys/x509_public_key.c |  6 ------
 3 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/crypto/asymmetric_keys/pkcs7_verify.c b/crypto/asymmetric_keys/pkcs7_verify.c
index 0b4d07aa88111..f94a1d1ad3a6c 100644
--- a/crypto/asymmetric_keys/pkcs7_verify.c
+++ b/crypto/asymmetric_keys/pkcs7_verify.c
@@ -174,12 +174,6 @@ static int pkcs7_find_key(struct pkcs7_message *pkcs7,
 		pr_devel("Sig %u: Found cert serial match X.509[%u]\n",
 			 sinfo->index, certix);
 
-		if (strcmp(x509->pub->pkey_algo, sinfo->sig->pkey_algo) != 0) {
-			pr_warn("Sig %u: X.509 algo and PKCS#7 sig algo don't match\n",
-				sinfo->index);
-			continue;
-		}
-
 		sinfo->signer = x509;
 		return 0;
 	}
diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c
index 4fefb219bfdc8..aba7113d86c76 100644
--- a/crypto/asymmetric_keys/public_key.c
+++ b/crypto/asymmetric_keys/public_key.c
@@ -325,6 +325,21 @@ int public_key_verify_signature(const struct public_key *pkey,
 	BUG_ON(!sig);
 	BUG_ON(!sig->s);
 
+	/*
+	 * The signature's claimed public key algorithm *must* match the key's
+	 * actual public key algorithm.
+	 *
+	 * Small exception: ECDSA signatures don't specify the curve, but ECDSA
+	 * keys do.  So the strings can mismatch slightly in that case:
+	 * "ecdsa-nist-*" for the key, but "ecdsa" for the signature.
+	 */
+	if (!sig->pkey_algo)
+		return -EINVAL;
+	if (strcmp(pkey->pkey_algo, sig->pkey_algo) != 0 &&
+	    (strncmp(pkey->pkey_algo, "ecdsa-", 6) != 0 ||
+	     strcmp(sig->pkey_algo, "ecdsa") != 0))
+		return -EKEYREJECTED;
+
 	ret = software_key_determine_akcipher(sig->encoding,
 					      sig->hash_algo,
 					      pkey, alg_name);
diff --git a/crypto/asymmetric_keys/x509_public_key.c b/crypto/asymmetric_keys/x509_public_key.c
index fe14cae115b51..71cc1738fbfd2 100644
--- a/crypto/asymmetric_keys/x509_public_key.c
+++ b/crypto/asymmetric_keys/x509_public_key.c
@@ -128,12 +128,6 @@ int x509_check_for_self_signed(struct x509_certificate *cert)
 			goto out;
 	}
 
-	ret = -EKEYREJECTED;
-	if (strcmp(cert->pub->pkey_algo, cert->sig->pkey_algo) != 0 &&
-	    (strncmp(cert->pub->pkey_algo, "ecdsa-", 6) != 0 ||
-	     strcmp(cert->sig->pkey_algo, "ecdsa") != 0))
-		goto out;
-
 	ret = public_key_verify_signature(cert->pub, cert->sig);
 	if (ret < 0) {
 		if (ret == -ENOPKG) {
-- 
2.35.1


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

* [PATCH 2/2] KEYS: asymmetric: properly validate hash_algo and encoding
  2022-02-01  0:34 [PATCH 0/2] Fix bugs in public_key_verify_signature() Eric Biggers
  2022-02-01  0:34 ` [PATCH 1/2] KEYS: asymmetric: enforce that sig algo matches key algo Eric Biggers
@ 2022-02-01  0:34 ` Eric Biggers
  2022-02-21  1:46   ` Jarkko Sakkinen
  2022-02-01  2:38 ` [PATCH 0/2] Fix bugs in public_key_verify_signature() Stefan Berger
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 21+ messages in thread
From: Eric Biggers @ 2022-02-01  0:34 UTC (permalink / raw)
  To: keyrings, Jarkko Sakkinen, David Howells
  Cc: linux-crypto, linux-integrity, Stefan Berger, Gilad Ben-Yossef,
	Tianjia Zhang, Vitaly Chikunov, Mimi Zohar, stable

From: Eric Biggers <ebiggers@google.com>

It is insecure to allow arbitrary hash algorithms and signature
encodings to be used with arbitrary signature algorithms.  Notably,
ECDSA, ECRDSA, and SM2 all sign/verify raw hash values and don't
disambiguate between different hash algorithms like RSA PKCS#1 v1.5
padding does.  Therefore, they need to be restricted to certain sets of
hash algorithms (ideally just one, but in practice small sets are used).
Additionally, the encoding is an integral part of modern signature
algorithms, and is not supposed to vary.

Therefore, tighten the checks of hash_algo and encoding done by
software_key_determine_akcipher().

Also rearrange the parameters to software_key_determine_akcipher() to
put the public_key first, as this is the most important parameter and it
often determines everything else.

Fixes: 299f561a6693 ("x509: Add support for parsing x509 certs with ECDSA keys")
Fixes: 215525639631 ("X.509: support OSCCA SM2-with-SM3 certificate verification")
Fixes: 0d7a78643f69 ("crypto: ecrdsa - add EC-RDSA (GOST 34.10) algorithm")
Cc: stable@vger.kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 crypto/asymmetric_keys/public_key.c | 111 +++++++++++++++++++---------
 1 file changed, 76 insertions(+), 35 deletions(-)

diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c
index aba7113d86c76..a603ee8afdb8d 100644
--- a/crypto/asymmetric_keys/public_key.c
+++ b/crypto/asymmetric_keys/public_key.c
@@ -60,39 +60,83 @@ static void public_key_destroy(void *payload0, void *payload3)
 }
 
 /*
- * Determine the crypto algorithm name.
+ * Given a public_key, and an encoding and hash_algo to be used for signing
+ * and/or verification with that key, determine the name of the corresponding
+ * akcipher algorithm.  Also check that encoding and hash_algo are allowed.
  */
-static
-int software_key_determine_akcipher(const char *encoding,
-				    const char *hash_algo,
-				    const struct public_key *pkey,
-				    char alg_name[CRYPTO_MAX_ALG_NAME])
+static int
+software_key_determine_akcipher(const struct public_key *pkey,
+				const char *encoding, const char *hash_algo,
+				char alg_name[CRYPTO_MAX_ALG_NAME])
 {
 	int n;
 
-	if (strcmp(encoding, "pkcs1") == 0) {
-		/* The data wangled by the RSA algorithm is typically padded
-		 * and encoded in some manner, such as EMSA-PKCS1-1_5 [RFC3447
-		 * sec 8.2].
+	if (!encoding)
+		return -EINVAL;
+
+	if (strcmp(pkey->pkey_algo, "rsa") == 0) {
+		/*
+		 * RSA signatures usually use EMSA-PKCS1-1_5 [RFC3447 sec 8.2].
+		 */
+		if (strcmp(encoding, "pkcs1") == 0) {
+			if (!hash_algo)
+				n = snprintf(alg_name, CRYPTO_MAX_ALG_NAME,
+					     "pkcs1pad(%s)",
+					     pkey->pkey_algo);
+			else
+				n = snprintf(alg_name, CRYPTO_MAX_ALG_NAME,
+					     "pkcs1pad(%s,%s)",
+					     pkey->pkey_algo, hash_algo);
+			return n >= CRYPTO_MAX_ALG_NAME ? -EINVAL : 0;
+		}
+		if (strcmp(encoding, "raw") != 0)
+			return -EINVAL;
+		/*
+		 * Raw RSA cannot differentiate between different hash
+		 * algorithms.
+		 */
+		if (hash_algo)
+			return -EINVAL;
+	} else if (strncmp(pkey->pkey_algo, "ecdsa", 5) == 0) {
+		if (strcmp(encoding, "x962") != 0)
+			return -EINVAL;
+		/*
+		 * ECDSA signatures are taken over a raw hash, so they don't
+		 * differentiate between different hash algorithms.  That means
+		 * that the verifier should hard-code a specific hash algorithm.
+		 * Unfortunately, in practice ECDSA is used with multiple SHAs,
+		 * so we have to allow all of them and not just one.
 		 */
 		if (!hash_algo)
-			n = snprintf(alg_name, CRYPTO_MAX_ALG_NAME,
-				     "pkcs1pad(%s)",
-				     pkey->pkey_algo);
-		else
-			n = snprintf(alg_name, CRYPTO_MAX_ALG_NAME,
-				     "pkcs1pad(%s,%s)",
-				     pkey->pkey_algo, hash_algo);
-		return n >= CRYPTO_MAX_ALG_NAME ? -EINVAL : 0;
-	}
-
-	if (strcmp(encoding, "raw") == 0 ||
-	    strcmp(encoding, "x962") == 0) {
-		strcpy(alg_name, pkey->pkey_algo);
-		return 0;
+			return -EINVAL;
+		if (strcmp(hash_algo, "sha1") != 0 &&
+		    strcmp(hash_algo, "sha224") != 0 &&
+		    strcmp(hash_algo, "sha256") != 0 &&
+		    strcmp(hash_algo, "sha384") != 0 &&
+		    strcmp(hash_algo, "sha512") != 0)
+			return -EINVAL;
+	} else if (strcmp(pkey->pkey_algo, "sm2") == 0) {
+		if (strcmp(encoding, "raw") != 0)
+			return -EINVAL;
+		if (!hash_algo)
+			return -EINVAL;
+		if (strcmp(hash_algo, "sm3") != 0)
+			return -EINVAL;
+	} else if (strcmp(pkey->pkey_algo, "ecrdsa") == 0) {
+		if (strcmp(encoding, "raw") != 0)
+			return -EINVAL;
+		if (!hash_algo)
+			return -EINVAL;
+		if (strcmp(hash_algo, "streebog256") != 0 &&
+		    strcmp(hash_algo, "streebog512") != 0)
+			return -EINVAL;
+	} else {
+		/* Unknown public key algorithm */
+		return -ENOPKG;
 	}
-
-	return -ENOPKG;
+	if (strscpy(alg_name, pkey->pkey_algo, CRYPTO_MAX_ALG_NAME) < 0)
+		return -EINVAL;
+	return 0;
 }
 
 static u8 *pkey_pack_u32(u8 *dst, u32 val)
@@ -113,9 +157,8 @@ static int software_key_query(const struct kernel_pkey_params *params,
 	u8 *key, *ptr;
 	int ret, len;
 
-	ret = software_key_determine_akcipher(params->encoding,
-					      params->hash_algo,
-					      pkey, alg_name);
+	ret = software_key_determine_akcipher(pkey, params->encoding,
+					      params->hash_algo, alg_name);
 	if (ret < 0)
 		return ret;
 
@@ -179,9 +222,8 @@ static int software_key_eds_op(struct kernel_pkey_params *params,
 
 	pr_devel("==>%s()\n", __func__);
 
-	ret = software_key_determine_akcipher(params->encoding,
-					      params->hash_algo,
-					      pkey, alg_name);
+	ret = software_key_determine_akcipher(pkey, params->encoding,
+					      params->hash_algo, alg_name);
 	if (ret < 0)
 		return ret;
 
@@ -340,9 +382,8 @@ int public_key_verify_signature(const struct public_key *pkey,
 	     strcmp(sig->pkey_algo, "ecdsa") != 0))
 		return -EKEYREJECTED;
 
-	ret = software_key_determine_akcipher(sig->encoding,
-					      sig->hash_algo,
-					      pkey, alg_name);
+	ret = software_key_determine_akcipher(pkey, sig->encoding,
+					      sig->hash_algo, alg_name);
 	if (ret < 0)
 		return ret;
 
-- 
2.35.1


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

* Re: [PATCH 0/2] Fix bugs in public_key_verify_signature()
  2022-02-01  0:34 [PATCH 0/2] Fix bugs in public_key_verify_signature() Eric Biggers
  2022-02-01  0:34 ` [PATCH 1/2] KEYS: asymmetric: enforce that sig algo matches key algo Eric Biggers
  2022-02-01  0:34 ` [PATCH 2/2] KEYS: asymmetric: properly validate hash_algo and encoding Eric Biggers
@ 2022-02-01  2:38 ` Stefan Berger
  2022-02-07  7:45 ` Tianjia Zhang
  2022-02-07 11:43 ` [PATCH] KEYS: asymmetric: enforce SM2 signature use pkey algo Tianjia Zhang
  4 siblings, 0 replies; 21+ messages in thread
From: Stefan Berger @ 2022-02-01  2:38 UTC (permalink / raw)
  To: Eric Biggers, keyrings, Jarkko Sakkinen, David Howells
  Cc: linux-crypto, linux-integrity, Gilad Ben-Yossef, Tianjia Zhang,
	Vitaly Chikunov, Mimi Zohar


On 1/31/22 19:34, Eric Biggers wrote:
> This patchset fixes some bugs in public_key_verify_signature() where it
> could be tricked into using the wrong algorithm, as was discussed at
> https://lore.kernel.org/linux-integrity/20211202215507.298415-1-zohar@linux.ibm.com/T/#t
>
> I'd appreciate it if the people who care about each of the supported
> public key algorithms (RSA, ECDSA, ECRDSA, and SM2) would test this
> patchset to make sure it still works for their use case(s).  I've tested
> that X.509 and PKCS#7 with RSA still work.

I have tested that self-ECDSA-signed x.509 certs can still be loaded and 
ECDSA-signed files are still verified by IMA. It works for NIST P256 and 
P384.

Tested-by: Stefan Berger <stefanb@linux.ibm.com>


>
> Note, I have *not* included a fix for SM2 being implemented incorrectly.
> That is another bug that I pointed out in the above thread.  I think
> that bug is for the people who actually care about SM2.
>
> This applies to v5.17-rc2.
>
> Eric Biggers (2):
>    KEYS: asymmetric: enforce that sig algo matches key algo
>    KEYS: asymmetric: properly validate hash_algo and encoding
>
>   crypto/asymmetric_keys/pkcs7_verify.c    |   6 --
>   crypto/asymmetric_keys/public_key.c      | 126 ++++++++++++++++-------
>   crypto/asymmetric_keys/x509_public_key.c |   6 --
>   3 files changed, 91 insertions(+), 47 deletions(-)
>
>
> base-commit: 26291c54e111ff6ba87a164d85d4a4e134b7315c

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

* Re: [PATCH 1/2] KEYS: asymmetric: enforce that sig algo matches key algo
  2022-02-01  0:34 ` [PATCH 1/2] KEYS: asymmetric: enforce that sig algo matches key algo Eric Biggers
@ 2022-02-02  2:52   ` Vitaly Chikunov
  2022-02-02  3:10     ` Eric Biggers
  2022-02-21  1:43   ` Jarkko Sakkinen
  1 sibling, 1 reply; 21+ messages in thread
From: Vitaly Chikunov @ 2022-02-02  2:52 UTC (permalink / raw)
  To: Eric Biggers
  Cc: keyrings, Jarkko Sakkinen, David Howells, linux-crypto,
	linux-integrity, Stefan Berger, Gilad Ben-Yossef, Tianjia Zhang,
	Mimi Zohar, stable

Eric,

On Mon, Jan 31, 2022 at 04:34:13PM -0800, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> Most callers of public_key_verify_signature(), including most indirect
> callers via verify_signature() as well as pkcs7_verify_sig_chain(),
> don't check that public_key_signature::pkey_algo matches
> public_key::pkey_algo.  These should always match.

Why should they match?

public_key_signature is the data prepared to verify the cert's
signature. The cert's signature algorithm could be different from the
public key algorithm defined in the cert itself. They should match only
for self-signed certs. For example, you should be able to sign RSA
public key with ECDSA signature and vice versa. Or 256-bit EC-RDSA with
512-bit EC-RDSA. This check will prevent this.


> However, a malicious
> signature could intentionally declare an unintended algorithm.  It is
> essential that such signatures be rejected outright, or that the
> algorithm of the *key* be used -- not the algorithm of the signature as
> that would allow attackers to choose the algorithm used.
> 
> Currently, public_key_verify_signature() correctly uses the key's
> algorithm when deciding which akcipher to allocate.  That's good.
> However, it uses the signature's algorithm when deciding whether to do
> the first step of SM2, which is incorrect.  Also, v4.19 and older
> kernels used the signature's algorithm for the entire process.
> 
> Prevent such errors by making public_key_verify_signature() enforce that
> the signature's algorithm matches the key's algorithm.
> 
> Also remove two checks of this done by callers, which are now redundant.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
>  crypto/asymmetric_keys/pkcs7_verify.c    |  6 ------
>  crypto/asymmetric_keys/public_key.c      | 15 +++++++++++++++
>  crypto/asymmetric_keys/x509_public_key.c |  6 ------
>  3 files changed, 15 insertions(+), 12 deletions(-)
> 
> diff --git a/crypto/asymmetric_keys/pkcs7_verify.c b/crypto/asymmetric_keys/pkcs7_verify.c
> index 0b4d07aa88111..f94a1d1ad3a6c 100644
> --- a/crypto/asymmetric_keys/pkcs7_verify.c
> +++ b/crypto/asymmetric_keys/pkcs7_verify.c
> @@ -174,12 +174,6 @@ static int pkcs7_find_key(struct pkcs7_message *pkcs7,
>  		pr_devel("Sig %u: Found cert serial match X.509[%u]\n",
>  			 sinfo->index, certix);
>  
> -		if (strcmp(x509->pub->pkey_algo, sinfo->sig->pkey_algo) != 0) {
> -			pr_warn("Sig %u: X.509 algo and PKCS#7 sig algo don't match\n",
> -				sinfo->index);
> -			continue;
> -		}
> -
>  		sinfo->signer = x509;
>  		return 0;
>  	}
> diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c
> index 4fefb219bfdc8..aba7113d86c76 100644
> --- a/crypto/asymmetric_keys/public_key.c
> +++ b/crypto/asymmetric_keys/public_key.c
> @@ -325,6 +325,21 @@ int public_key_verify_signature(const struct public_key *pkey,
>  	BUG_ON(!sig);
>  	BUG_ON(!sig->s);
>  
> +	/*
> +	 * The signature's claimed public key algorithm *must* match the key's
> +	 * actual public key algorithm.
> +	 *
> +	 * Small exception: ECDSA signatures don't specify the curve, but ECDSA
> +	 * keys do.  So the strings can mismatch slightly in that case:
> +	 * "ecdsa-nist-*" for the key, but "ecdsa" for the signature.
> +	 */
> +	if (!sig->pkey_algo)
> +		return -EINVAL;

This seem incorrect too, as sig->pkey_algo could be NULL for direct
signature verification calls. For example, for keyctl pkey_verify.

(Side note: keyctl pkey_verify will not work for non-RSA signatures,
though, due to other bug - because signature size is twice key size for
them, but akcipher_alg::max_size cannot distinguish this, and
max_data_size, key_size, and max_sig_size are set from it).

> +	if (strcmp(pkey->pkey_algo, sig->pkey_algo) != 0 &&
> +	    (strncmp(pkey->pkey_algo, "ecdsa-", 6) != 0 ||
> +	     strcmp(sig->pkey_algo, "ecdsa") != 0))

This seems to be taken from x509_check_for_self_signed, that's why this
should not work for non-self-signed certs.

Thanks,

> +		return -EKEYREJECTED;
> +
>  	ret = software_key_determine_akcipher(sig->encoding,
>  					      sig->hash_algo,
>  					      pkey, alg_name);
> diff --git a/crypto/asymmetric_keys/x509_public_key.c b/crypto/asymmetric_keys/x509_public_key.c
> index fe14cae115b51..71cc1738fbfd2 100644
> --- a/crypto/asymmetric_keys/x509_public_key.c
> +++ b/crypto/asymmetric_keys/x509_public_key.c
> @@ -128,12 +128,6 @@ int x509_check_for_self_signed(struct x509_certificate *cert)
>  			goto out;
>  	}
>  
> -	ret = -EKEYREJECTED;
> -	if (strcmp(cert->pub->pkey_algo, cert->sig->pkey_algo) != 0 &&
> -	    (strncmp(cert->pub->pkey_algo, "ecdsa-", 6) != 0 ||
> -	     strcmp(cert->sig->pkey_algo, "ecdsa") != 0))
> -		goto out;
> -
>  	ret = public_key_verify_signature(cert->pub, cert->sig);
>  	if (ret < 0) {
>  		if (ret == -ENOPKG) {
> -- 
> 2.35.1

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

* Re: [PATCH 1/2] KEYS: asymmetric: enforce that sig algo matches key algo
  2022-02-02  2:52   ` Vitaly Chikunov
@ 2022-02-02  3:10     ` Eric Biggers
  2022-02-02  3:22       ` Eric Biggers
  2022-02-02  5:20       ` Vitaly Chikunov
  0 siblings, 2 replies; 21+ messages in thread
From: Eric Biggers @ 2022-02-02  3:10 UTC (permalink / raw)
  To: Vitaly Chikunov
  Cc: keyrings, Jarkko Sakkinen, David Howells, linux-crypto,
	linux-integrity, Stefan Berger, Gilad Ben-Yossef, Tianjia Zhang,
	Mimi Zohar, stable

On Wed, Feb 02, 2022 at 05:52:30AM +0300, Vitaly Chikunov wrote:
> Eric,
> 
> On Mon, Jan 31, 2022 at 04:34:13PM -0800, Eric Biggers wrote:
> > From: Eric Biggers <ebiggers@google.com>
> > 
> > Most callers of public_key_verify_signature(), including most indirect
> > callers via verify_signature() as well as pkcs7_verify_sig_chain(),
> > don't check that public_key_signature::pkey_algo matches
> > public_key::pkey_algo.  These should always match.
> 
> Why should they match?

For the reasons I explain in the rest of the commit message.  To summarize: to
have a valid signature verification scheme the algorithm must be fixed by the
key, and not attacker-controlled.

> 
> public_key_signature is the data prepared to verify the cert's
> signature. The cert's signature algorithm could be different from the
> public key algorithm defined in the cert itself. They should match only
> for self-signed certs. For example, you should be able to sign RSA
> public key with ECDSA signature and vice versa. Or 256-bit EC-RDSA with
> 512-bit EC-RDSA. This check will prevent this.

That has nothing to do with this patch, as this patch is only dealing with the
signature.  A cert's public key algorithm can be different, and that is fine.

> > diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c
> > index 4fefb219bfdc8..aba7113d86c76 100644
> > --- a/crypto/asymmetric_keys/public_key.c
> > +++ b/crypto/asymmetric_keys/public_key.c
> > @@ -325,6 +325,21 @@ int public_key_verify_signature(const struct public_key *pkey,
> >  	BUG_ON(!sig);
> >  	BUG_ON(!sig->s);
> >  
> > +	/*
> > +	 * The signature's claimed public key algorithm *must* match the key's
> > +	 * actual public key algorithm.
> > +	 *
> > +	 * Small exception: ECDSA signatures don't specify the curve, but ECDSA
> > +	 * keys do.  So the strings can mismatch slightly in that case:
> > +	 * "ecdsa-nist-*" for the key, but "ecdsa" for the signature.
> > +	 */
> > +	if (!sig->pkey_algo)
> > +		return -EINVAL;
> 
> This seem incorrect too, as sig->pkey_algo could be NULL for direct
> signature verification calls. For example, for keyctl pkey_verify.

We can make it optional if some callers aren't providing it.  Of course, such
callers wouldn't be able to verify ECDSA signatures.

- Eric

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

* Re: [PATCH 1/2] KEYS: asymmetric: enforce that sig algo matches key algo
  2022-02-02  3:10     ` Eric Biggers
@ 2022-02-02  3:22       ` Eric Biggers
  2022-02-02  5:20       ` Vitaly Chikunov
  1 sibling, 0 replies; 21+ messages in thread
From: Eric Biggers @ 2022-02-02  3:22 UTC (permalink / raw)
  To: Vitaly Chikunov
  Cc: keyrings, Jarkko Sakkinen, David Howells, linux-crypto,
	linux-integrity, Stefan Berger, Gilad Ben-Yossef, Tianjia Zhang,
	Mimi Zohar, stable

On Tue, Feb 01, 2022 at 07:10:33PM -0800, Eric Biggers wrote:
> > This seem incorrect too, as sig->pkey_algo could be NULL for direct
> > signature verification calls. For example, for keyctl pkey_verify.
> 
> We can make it optional if some callers aren't providing it.  Of course, such
> callers wouldn't be able to verify ECDSA signatures.

Sorry, I got that backwards.  ECDSA signatures don't specify the curve, but the
keys do (as I noted in a comment).  So ECDSA wouldn't require sig->pkey_algo.

Since it appears that KEYCTL_PKEY_VERIFY does in fact have no way to specify a
pkey_algo, I'll allow NULL pkey_algo in v2.

Note that SM2 isn't implemented correctly when sig->pkey_algo is NULL, as the
following code incorrectly uses the signature's pkey_algo rather than the key's:

        if (sig->pkey_algo && strcmp(sig->pkey_algo, "sm2") == 0 &&
            sig->data_size) {
                ret = cert_sig_digest_update(sig, tfm);
                if (ret)
                        goto error_free_key;
        }

I'm not sure whether I should even bother fixing that, given how broken the SM2
stuff is anyway.

- Eric

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

* Re: [PATCH 1/2] KEYS: asymmetric: enforce that sig algo matches key algo
  2022-02-02  3:10     ` Eric Biggers
  2022-02-02  3:22       ` Eric Biggers
@ 2022-02-02  5:20       ` Vitaly Chikunov
  1 sibling, 0 replies; 21+ messages in thread
From: Vitaly Chikunov @ 2022-02-02  5:20 UTC (permalink / raw)
  To: Eric Biggers
  Cc: keyrings, Jarkko Sakkinen, David Howells, linux-crypto,
	linux-integrity, Stefan Berger, Gilad Ben-Yossef, Tianjia Zhang,
	Mimi Zohar, stable

On Tue, Feb 01, 2022 at 07:10:33PM -0800, Eric Biggers wrote:
> On Wed, Feb 02, 2022 at 05:52:30AM +0300, Vitaly Chikunov wrote:
> > Eric,
> > 
> > On Mon, Jan 31, 2022 at 04:34:13PM -0800, Eric Biggers wrote:
> > > From: Eric Biggers <ebiggers@google.com>
> > > 
> > > Most callers of public_key_verify_signature(), including most indirect
> > > callers via verify_signature() as well as pkcs7_verify_sig_chain(),
> > > don't check that public_key_signature::pkey_algo matches
> > > public_key::pkey_algo.  These should always match.
> > 
> > Why should they match?
> 
> For the reasons I explain in the rest of the commit message.  To summarize: to
> have a valid signature verification scheme the algorithm must be fixed by the
> key, and not attacker-controlled.
> 
> > 
> > public_key_signature is the data prepared to verify the cert's
> > signature. The cert's signature algorithm could be different from the
> > public key algorithm defined in the cert itself. They should match only
> > for self-signed certs. For example, you should be able to sign RSA
> > public key with ECDSA signature and vice versa. Or 256-bit EC-RDSA with
> > 512-bit EC-RDSA. This check will prevent this.
> 
> That has nothing to do with this patch, as this patch is only dealing with the
> signature.  A cert's public key algorithm can be different, and that is fine.

You are right and I was mistaken about that (obscured by keyctl
pkey_verify error and self-signed keys verification). Then it's all
good!

I also tested these patches to work well with rsa-ecdsa and ecrdsa
certificates using keyctl restrict_keyring.

Thanks,

> 
> > > diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c
> > > index 4fefb219bfdc8..aba7113d86c76 100644
> > > --- a/crypto/asymmetric_keys/public_key.c
> > > +++ b/crypto/asymmetric_keys/public_key.c
> > > @@ -325,6 +325,21 @@ int public_key_verify_signature(const struct public_key *pkey,
> > >  	BUG_ON(!sig);
> > >  	BUG_ON(!sig->s);
> > >  
> > > +	/*
> > > +	 * The signature's claimed public key algorithm *must* match the key's
> > > +	 * actual public key algorithm.
> > > +	 *
> > > +	 * Small exception: ECDSA signatures don't specify the curve, but ECDSA
> > > +	 * keys do.  So the strings can mismatch slightly in that case:
> > > +	 * "ecdsa-nist-*" for the key, but "ecdsa" for the signature.
> > > +	 */
> > > +	if (!sig->pkey_algo)
> > > +		return -EINVAL;
> > 
> > This seem incorrect too, as sig->pkey_algo could be NULL for direct
> > signature verification calls. For example, for keyctl pkey_verify.
> 
> We can make it optional if some callers aren't providing it.  Of course, such
> callers wouldn't be able to verify ECDSA signatures.
> 
> - Eric

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

* Re: [PATCH 0/2] Fix bugs in public_key_verify_signature()
  2022-02-01  0:34 [PATCH 0/2] Fix bugs in public_key_verify_signature() Eric Biggers
                   ` (2 preceding siblings ...)
  2022-02-01  2:38 ` [PATCH 0/2] Fix bugs in public_key_verify_signature() Stefan Berger
@ 2022-02-07  7:45 ` Tianjia Zhang
  2022-02-07 11:43 ` [PATCH] KEYS: asymmetric: enforce SM2 signature use pkey algo Tianjia Zhang
  4 siblings, 0 replies; 21+ messages in thread
From: Tianjia Zhang @ 2022-02-07  7:45 UTC (permalink / raw)
  To: Eric Biggers, keyrings, Jarkko Sakkinen, David Howells
  Cc: linux-crypto, linux-integrity, Stefan Berger, Gilad Ben-Yossef,
	Vitaly Chikunov, Mimi Zohar

Hi Eric,

On 2/1/22 8:34 AM, Eric Biggers wrote:
> This patchset fixes some bugs in public_key_verify_signature() where it
> could be tricked into using the wrong algorithm, as was discussed at
> https://lore.kernel.org/linux-integrity/20211202215507.298415-1-zohar@linux.ibm.com/T/#t
> 
> I'd appreciate it if the people who care about each of the supported
> public key algorithms (RSA, ECDSA, ECRDSA, and SM2) would test this
> patchset to make sure it still works for their use case(s).  I've tested
> that X.509 and PKCS#7 with RSA still work.
> 
> Note, I have *not* included a fix for SM2 being implemented incorrectly.
> That is another bug that I pointed out in the above thread.  I think
> that bug is for the people who actually care about SM2.
> 
> This applies to v5.17-rc2.
> 

Sorry for the late reply, thanks for your work.

I did the test and the x509 certificate for SM2-with-SM3 is working
fine.

Tested-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>

Regarding the algorithm information in the signature data used by SM2,
I will add a patch to fix this issue, thanks for pointing it out.

Best regards,
Tianjia

> Eric Biggers (2):
>    KEYS: asymmetric: enforce that sig algo matches key algo
>    KEYS: asymmetric: properly validate hash_algo and encoding
> 
>   crypto/asymmetric_keys/pkcs7_verify.c    |   6 --
>   crypto/asymmetric_keys/public_key.c      | 126 ++++++++++++++++-------
>   crypto/asymmetric_keys/x509_public_key.c |   6 --
>   3 files changed, 91 insertions(+), 47 deletions(-)
> 
> 
> base-commit: 26291c54e111ff6ba87a164d85d4a4e134b7315c

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

* [PATCH] KEYS: asymmetric: enforce SM2 signature use pkey algo
  2022-02-01  0:34 [PATCH 0/2] Fix bugs in public_key_verify_signature() Eric Biggers
                   ` (3 preceding siblings ...)
  2022-02-07  7:45 ` Tianjia Zhang
@ 2022-02-07 11:43 ` Tianjia Zhang
  2022-02-08  5:35   ` Eric Biggers
  2022-02-21  1:49   ` Jarkko Sakkinen
  4 siblings, 2 replies; 21+ messages in thread
From: Tianjia Zhang @ 2022-02-07 11:43 UTC (permalink / raw)
  To: Eric Biggers, Mimi Zohar, Vitaly Chikunov, Stefan Berger,
	Jarkko Sakkinen, Gilad Ben-Yossef, David Howells, Herbert Xu,
	David S. Miller, keyrings, linux-crypto, linux-integrity
  Cc: Tianjia Zhang

The signature verification of SM2 needs to add the Za value and
recalculate sig->digest, which requires the detection of the pkey_algo
in public_key_verify_signature(). As Eric Biggers said, the pkey_algo
field in sig is attacker-controlled and should be use pkey->pkey_algo
instead of sig->pkey_algo, and secondly, if sig->pkey_algo is NULL, it
will also cause signature verification failure.

The software_key_determine_akcipher() already forces the algorithms
are matched, so the SM3 algorithm is enforced in the SM2 signature,
although this has been checked, we still avoid using any algorithm
information in the signature as input.

Reported-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
---
 crypto/asymmetric_keys/public_key.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c
index a603ee8afdb8..ea9a5501f87e 100644
--- a/crypto/asymmetric_keys/public_key.c
+++ b/crypto/asymmetric_keys/public_key.c
@@ -309,7 +309,8 @@ static int cert_sig_digest_update(const struct public_key_signature *sig,
 	if (ret)
 		return ret;
 
-	tfm = crypto_alloc_shash(sig->hash_algo, 0, 0);
+	/* SM2 signatures always use the SM3 hash algorithm */
+	tfm = crypto_alloc_shash("sm3", 0, 0);
 	if (IS_ERR(tfm))
 		return PTR_ERR(tfm);
 
@@ -414,8 +415,7 @@ int public_key_verify_signature(const struct public_key *pkey,
 	if (ret)
 		goto error_free_key;
 
-	if (sig->pkey_algo && strcmp(sig->pkey_algo, "sm2") == 0 &&
-	    sig->data_size) {
+	if (strcmp(pkey->pkey_algo, "sm2") == 0 && sig->data_size) {
 		ret = cert_sig_digest_update(sig, tfm);
 		if (ret)
 			goto error_free_key;
-- 
2.34.1


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

* Re: [PATCH] KEYS: asymmetric: enforce SM2 signature use pkey algo
  2022-02-07 11:43 ` [PATCH] KEYS: asymmetric: enforce SM2 signature use pkey algo Tianjia Zhang
@ 2022-02-08  5:35   ` Eric Biggers
  2022-02-08  9:45     ` Tianjia Zhang
  2022-02-21  1:49   ` Jarkko Sakkinen
  1 sibling, 1 reply; 21+ messages in thread
From: Eric Biggers @ 2022-02-08  5:35 UTC (permalink / raw)
  To: Tianjia Zhang
  Cc: Mimi Zohar, Vitaly Chikunov, Stefan Berger, Jarkko Sakkinen,
	Gilad Ben-Yossef, David Howells, Herbert Xu, David S. Miller,
	keyrings, linux-crypto, linux-integrity

On Mon, Feb 07, 2022 at 07:43:27PM +0800, Tianjia Zhang wrote:
> The signature verification of SM2 needs to add the Za value and
> recalculate sig->digest, which requires the detection of the pkey_algo
> in public_key_verify_signature(). As Eric Biggers said, the pkey_algo
> field in sig is attacker-controlled and should be use pkey->pkey_algo
> instead of sig->pkey_algo, and secondly, if sig->pkey_algo is NULL, it
> will also cause signature verification failure.
> 
> The software_key_determine_akcipher() already forces the algorithms
> are matched, so the SM3 algorithm is enforced in the SM2 signature,
> although this has been checked, we still avoid using any algorithm
> information in the signature as input.
> 
> Reported-by: Eric Biggers <ebiggers@google.com>
> Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>

Can you add a Fixes tag?

> ---
>  crypto/asymmetric_keys/public_key.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c
> index a603ee8afdb8..ea9a5501f87e 100644
> --- a/crypto/asymmetric_keys/public_key.c
> +++ b/crypto/asymmetric_keys/public_key.c
> @@ -309,7 +309,8 @@ static int cert_sig_digest_update(const struct public_key_signature *sig,
>  	if (ret)
>  		return ret;
>  
> -	tfm = crypto_alloc_shash(sig->hash_algo, 0, 0);
> +	/* SM2 signatures always use the SM3 hash algorithm */
> +	tfm = crypto_alloc_shash("sm3", 0, 0);
>  	if (IS_ERR(tfm))
>  		return PTR_ERR(tfm);
>  
> @@ -414,8 +415,7 @@ int public_key_verify_signature(const struct public_key *pkey,
>  	if (ret)
>  		goto error_free_key;
>  
> -	if (sig->pkey_algo && strcmp(sig->pkey_algo, "sm2") == 0 &&
> -	    sig->data_size) {
> +	if (strcmp(pkey->pkey_algo, "sm2") == 0 && sig->data_size) {
>  		ret = cert_sig_digest_update(sig, tfm);
>  		if (ret)
>  			goto error_free_key;
> -- 

This is an improvement, but do you also have a plan to address the problem where
the code allows the "Za" hash step to be skipped?  The definitions of SM2 that I
could find require that step.  So, it is unclear that the algorithm with that
step skipped is still SM2, and how its security relates to that of the SM2
algorithm as actually defined.

- Eric

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

* Re: [PATCH] KEYS: asymmetric: enforce SM2 signature use pkey algo
  2022-02-08  5:35   ` Eric Biggers
@ 2022-02-08  9:45     ` Tianjia Zhang
  0 siblings, 0 replies; 21+ messages in thread
From: Tianjia Zhang @ 2022-02-08  9:45 UTC (permalink / raw)
  To: Eric Biggers
  Cc: Mimi Zohar, Vitaly Chikunov, Stefan Berger, Jarkko Sakkinen,
	Gilad Ben-Yossef, David Howells, Herbert Xu, David S. Miller,
	keyrings, linux-crypto, linux-integrity

Hi Eric,

On 2/8/22 1:35 PM, Eric Biggers wrote:
> On Mon, Feb 07, 2022 at 07:43:27PM +0800, Tianjia Zhang wrote:
>> The signature verification of SM2 needs to add the Za value and
>> recalculate sig->digest, which requires the detection of the pkey_algo
>> in public_key_verify_signature(). As Eric Biggers said, the pkey_algo
>> field in sig is attacker-controlled and should be use pkey->pkey_algo
>> instead of sig->pkey_algo, and secondly, if sig->pkey_algo is NULL, it
>> will also cause signature verification failure.
>>
>> The software_key_determine_akcipher() already forces the algorithms
>> are matched, so the SM3 algorithm is enforced in the SM2 signature,
>> although this has been checked, we still avoid using any algorithm
>> information in the signature as input.
>>
>> Reported-by: Eric Biggers <ebiggers@google.com>
>> Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
> 
> Can you add a Fixes tag?
> 

Thanks, the v2 patch with Fixes tag added has been appended to your
v2 series.

>> ---
>>   crypto/asymmetric_keys/public_key.c | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c
>> index a603ee8afdb8..ea9a5501f87e 100644
>> --- a/crypto/asymmetric_keys/public_key.c
>> +++ b/crypto/asymmetric_keys/public_key.c
>> @@ -309,7 +309,8 @@ static int cert_sig_digest_update(const struct public_key_signature *sig,
>>   	if (ret)
>>   		return ret;
>>   
>> -	tfm = crypto_alloc_shash(sig->hash_algo, 0, 0);
>> +	/* SM2 signatures always use the SM3 hash algorithm */
>> +	tfm = crypto_alloc_shash("sm3", 0, 0);
>>   	if (IS_ERR(tfm))
>>   		return PTR_ERR(tfm);
>>   
>> @@ -414,8 +415,7 @@ int public_key_verify_signature(const struct public_key *pkey,
>>   	if (ret)
>>   		goto error_free_key;
>>   
>> -	if (sig->pkey_algo && strcmp(sig->pkey_algo, "sm2") == 0 &&
>> -	    sig->data_size) {
>> +	if (strcmp(pkey->pkey_algo, "sm2") == 0 && sig->data_size) {
>>   		ret = cert_sig_digest_update(sig, tfm);
>>   		if (ret)
>>   			goto error_free_key;
>> -- 
> 
> This is an improvement, but do you also have a plan to address the problem where
> the code allows the "Za" hash step to be skipped?  The definitions of SM2 that I
> could find require that step.  So, it is unclear that the algorithm with that
> step skipped is still SM2, and how its security relates to that of the SM2
> algorithm as actually defined.
> 
> - Eric
The design of this Za has indeed brought us a lot of trouble, which
makes the two separate steps of calculating the hash and signature
forced to be coupled together. At present, it is a better way to design
skipping Za as an option. I will try to do this, which of course also
includes application layer libraries, like openssl.

Best regards,
Tianjia

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

* Re: [PATCH 1/2] KEYS: asymmetric: enforce that sig algo matches key algo
  2022-02-01  0:34 ` [PATCH 1/2] KEYS: asymmetric: enforce that sig algo matches key algo Eric Biggers
  2022-02-02  2:52   ` Vitaly Chikunov
@ 2022-02-21  1:43   ` Jarkko Sakkinen
  2022-03-04 19:26     ` Eric Biggers
  1 sibling, 1 reply; 21+ messages in thread
From: Jarkko Sakkinen @ 2022-02-21  1:43 UTC (permalink / raw)
  To: Eric Biggers, David Howells
  Cc: keyrings, linux-crypto, linux-integrity, Stefan Berger,
	Gilad Ben-Yossef, Tianjia Zhang, Vitaly Chikunov, Mimi Zohar,
	stable

On Mon, Jan 31, 2022 at 04:34:13PM -0800, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> Most callers of public_key_verify_signature(), including most indirect
> callers via verify_signature() as well as pkcs7_verify_sig_chain(),
> don't check that public_key_signature::pkey_algo matches
> public_key::pkey_algo.  These should always match.  However, a malicious
> signature could intentionally declare an unintended algorithm.  It is
> essential that such signatures be rejected outright, or that the
> algorithm of the *key* be used -- not the algorithm of the signature as
> that would allow attackers to choose the algorithm used.
> 
> Currently, public_key_verify_signature() correctly uses the key's
> algorithm when deciding which akcipher to allocate.  That's good.
> However, it uses the signature's algorithm when deciding whether to do
> the first step of SM2, which is incorrect.  Also, v4.19 and older
> kernels used the signature's algorithm for the entire process.
> 
> Prevent such errors by making public_key_verify_signature() enforce that
> the signature's algorithm matches the key's algorithm.
> 
> Also remove two checks of this done by callers, which are now redundant.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
>  crypto/asymmetric_keys/pkcs7_verify.c    |  6 ------
>  crypto/asymmetric_keys/public_key.c      | 15 +++++++++++++++
>  crypto/asymmetric_keys/x509_public_key.c |  6 ------
>  3 files changed, 15 insertions(+), 12 deletions(-)
> 
> diff --git a/crypto/asymmetric_keys/pkcs7_verify.c b/crypto/asymmetric_keys/pkcs7_verify.c
> index 0b4d07aa88111..f94a1d1ad3a6c 100644
> --- a/crypto/asymmetric_keys/pkcs7_verify.c
> +++ b/crypto/asymmetric_keys/pkcs7_verify.c
> @@ -174,12 +174,6 @@ static int pkcs7_find_key(struct pkcs7_message *pkcs7,
>  		pr_devel("Sig %u: Found cert serial match X.509[%u]\n",
>  			 sinfo->index, certix);
>  
> -		if (strcmp(x509->pub->pkey_algo, sinfo->sig->pkey_algo) != 0) {
> -			pr_warn("Sig %u: X.509 algo and PKCS#7 sig algo don't match\n",
> -				sinfo->index);
> -			continue;
> -		}
> -
>  		sinfo->signer = x509;
>  		return 0;
>  	}
> diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c
> index 4fefb219bfdc8..aba7113d86c76 100644
> --- a/crypto/asymmetric_keys/public_key.c
> +++ b/crypto/asymmetric_keys/public_key.c
> @@ -325,6 +325,21 @@ int public_key_verify_signature(const struct public_key *pkey,
>  	BUG_ON(!sig);
>  	BUG_ON(!sig->s);
>  
> +	/*
> +	 * The signature's claimed public key algorithm *must* match the key's
> +	 * actual public key algorithm.
> +	 *
> +	 * Small exception: ECDSA signatures don't specify the curve, but ECDSA
> +	 * keys do.  So the strings can mismatch slightly in that case:
> +	 * "ecdsa-nist-*" for the key, but "ecdsa" for the signature.
> +	 */
> +	if (!sig->pkey_algo)
> +		return -EINVAL;
> +	if (strcmp(pkey->pkey_algo, sig->pkey_algo) != 0 &&
> +	    (strncmp(pkey->pkey_algo, "ecdsa-", 6) != 0 ||
> +	     strcmp(sig->pkey_algo, "ecdsa") != 0))
> +		return -EKEYREJECTED;
> +
>  	ret = software_key_determine_akcipher(sig->encoding,
>  					      sig->hash_algo,
>  					      pkey, alg_name);
> diff --git a/crypto/asymmetric_keys/x509_public_key.c b/crypto/asymmetric_keys/x509_public_key.c
> index fe14cae115b51..71cc1738fbfd2 100644
> --- a/crypto/asymmetric_keys/x509_public_key.c
> +++ b/crypto/asymmetric_keys/x509_public_key.c
> @@ -128,12 +128,6 @@ int x509_check_for_self_signed(struct x509_certificate *cert)
>  			goto out;
>  	}
>  
> -	ret = -EKEYREJECTED;
> -	if (strcmp(cert->pub->pkey_algo, cert->sig->pkey_algo) != 0 &&
> -	    (strncmp(cert->pub->pkey_algo, "ecdsa-", 6) != 0 ||
> -	     strcmp(cert->sig->pkey_algo, "ecdsa") != 0))
> -		goto out;
> -
>  	ret = public_key_verify_signature(cert->pub, cert->sig);
>  	if (ret < 0) {
>  		if (ret == -ENOPKG) {
> -- 
> 2.35.1
> 

Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>

David, do you want to pick this?

BR, Jarkko

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

* Re: [PATCH 2/2] KEYS: asymmetric: properly validate hash_algo and encoding
  2022-02-01  0:34 ` [PATCH 2/2] KEYS: asymmetric: properly validate hash_algo and encoding Eric Biggers
@ 2022-02-21  1:46   ` Jarkko Sakkinen
  2022-02-21  2:21     ` Eric Biggers
  0 siblings, 1 reply; 21+ messages in thread
From: Jarkko Sakkinen @ 2022-02-21  1:46 UTC (permalink / raw)
  To: Eric Biggers
  Cc: keyrings, David Howells, linux-crypto, linux-integrity,
	Stefan Berger, Gilad Ben-Yossef, Tianjia Zhang, Vitaly Chikunov,
	Mimi Zohar, stable

On Mon, Jan 31, 2022 at 04:34:14PM -0800, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> It is insecure to allow arbitrary hash algorithms and signature
> encodings to be used with arbitrary signature algorithms.  Notably,
> ECDSA, ECRDSA, and SM2 all sign/verify raw hash values and don't
> disambiguate between different hash algorithms like RSA PKCS#1 v1.5
> padding does.  Therefore, they need to be restricted to certain sets of
> hash algorithms (ideally just one, but in practice small sets are used).
> Additionally, the encoding is an integral part of modern signature
> algorithms, and is not supposed to vary.
> 
> Therefore, tighten the checks of hash_algo and encoding done by
> software_key_determine_akcipher().
> 
> Also rearrange the parameters to software_key_determine_akcipher() to
> put the public_key first, as this is the most important parameter and it
> often determines everything else.
> 
> Fixes: 299f561a6693 ("x509: Add support for parsing x509 certs with ECDSA keys")
> Fixes: 215525639631 ("X.509: support OSCCA SM2-with-SM3 certificate verification")
> Fixes: 0d7a78643f69 ("crypto: ecrdsa - add EC-RDSA (GOST 34.10) algorithm")
> Cc: stable@vger.kernel.org
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
>  crypto/asymmetric_keys/public_key.c | 111 +++++++++++++++++++---------
>  1 file changed, 76 insertions(+), 35 deletions(-)
> 
> diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c
> index aba7113d86c76..a603ee8afdb8d 100644
> --- a/crypto/asymmetric_keys/public_key.c
> +++ b/crypto/asymmetric_keys/public_key.c
> @@ -60,39 +60,83 @@ static void public_key_destroy(void *payload0, void *payload3)
>  }
>  
>  /*
> - * Determine the crypto algorithm name.
> + * Given a public_key, and an encoding and hash_algo to be used for signing
> + * and/or verification with that key, determine the name of the corresponding
> + * akcipher algorithm.  Also check that encoding and hash_algo are allowed.
>   */
> -static
> -int software_key_determine_akcipher(const char *encoding,
> -				    const char *hash_algo,
> -				    const struct public_key *pkey,
> -				    char alg_name[CRYPTO_MAX_ALG_NAME])
> +static int
> +software_key_determine_akcipher(const struct public_key *pkey,
> +				const char *encoding, const char *hash_algo,
> +				char alg_name[CRYPTO_MAX_ALG_NAME])

Why is changing parameter order necessary?

BR, Jarkko

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

* Re: [PATCH] KEYS: asymmetric: enforce SM2 signature use pkey algo
  2022-02-07 11:43 ` [PATCH] KEYS: asymmetric: enforce SM2 signature use pkey algo Tianjia Zhang
  2022-02-08  5:35   ` Eric Biggers
@ 2022-02-21  1:49   ` Jarkko Sakkinen
  2022-02-21  2:43     ` Tianjia Zhang
  1 sibling, 1 reply; 21+ messages in thread
From: Jarkko Sakkinen @ 2022-02-21  1:49 UTC (permalink / raw)
  To: Tianjia Zhang
  Cc: Eric Biggers, Mimi Zohar, Vitaly Chikunov, Stefan Berger,
	Gilad Ben-Yossef, David Howells, Herbert Xu, David S. Miller,
	keyrings, linux-crypto, linux-integrity

On Mon, Feb 07, 2022 at 07:43:27PM +0800, Tianjia Zhang wrote:
> The signature verification of SM2 needs to add the Za value and
> recalculate sig->digest, which requires the detection of the pkey_algo
> in public_key_verify_signature(). As Eric Biggers said, the pkey_algo
> field in sig is attacker-controlled and should be use pkey->pkey_algo
> instead of sig->pkey_algo, and secondly, if sig->pkey_algo is NULL, it
> will also cause signature verification failure.
> 
> The software_key_determine_akcipher() already forces the algorithms
> are matched, so the SM3 algorithm is enforced in the SM2 signature,
> although this has been checked, we still avoid using any algorithm
> information in the signature as input.
> 
> Reported-by: Eric Biggers <ebiggers@google.com>
> Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
> ---
>  crypto/asymmetric_keys/public_key.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c
> index a603ee8afdb8..ea9a5501f87e 100644
> --- a/crypto/asymmetric_keys/public_key.c
> +++ b/crypto/asymmetric_keys/public_key.c
> @@ -309,7 +309,8 @@ static int cert_sig_digest_update(const struct public_key_signature *sig,
>  	if (ret)
>  		return ret;
>  
> -	tfm = crypto_alloc_shash(sig->hash_algo, 0, 0);
> +	/* SM2 signatures always use the SM3 hash algorithm */
> +	tfm = crypto_alloc_shash("sm3", 0, 0);

Why not simply fail when sig->hash_algo != "sm3"?

BR, Jarkko

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

* Re: [PATCH 2/2] KEYS: asymmetric: properly validate hash_algo and encoding
  2022-02-21  1:46   ` Jarkko Sakkinen
@ 2022-02-21  2:21     ` Eric Biggers
  2022-02-21 20:16       ` Jarkko Sakkinen
  0 siblings, 1 reply; 21+ messages in thread
From: Eric Biggers @ 2022-02-21  2:21 UTC (permalink / raw)
  To: Jarkko Sakkinen
  Cc: keyrings, David Howells, linux-crypto, linux-integrity,
	Stefan Berger, Gilad Ben-Yossef, Tianjia Zhang, Vitaly Chikunov,
	Mimi Zohar, stable

On Mon, Feb 21, 2022 at 02:46:26AM +0100, Jarkko Sakkinen wrote:
> On Mon, Jan 31, 2022 at 04:34:14PM -0800, Eric Biggers wrote:
> > From: Eric Biggers <ebiggers@google.com>
> > 
> > It is insecure to allow arbitrary hash algorithms and signature
> > encodings to be used with arbitrary signature algorithms.  Notably,
> > ECDSA, ECRDSA, and SM2 all sign/verify raw hash values and don't
> > disambiguate between different hash algorithms like RSA PKCS#1 v1.5
> > padding does.  Therefore, they need to be restricted to certain sets of
> > hash algorithms (ideally just one, but in practice small sets are used).
> > Additionally, the encoding is an integral part of modern signature
> > algorithms, and is not supposed to vary.
> > 
> > Therefore, tighten the checks of hash_algo and encoding done by
> > software_key_determine_akcipher().
> > 
> > Also rearrange the parameters to software_key_determine_akcipher() to
> > put the public_key first, as this is the most important parameter and it
> > often determines everything else.
> > 
> > Fixes: 299f561a6693 ("x509: Add support for parsing x509 certs with ECDSA keys")
> > Fixes: 215525639631 ("X.509: support OSCCA SM2-with-SM3 certificate verification")
> > Fixes: 0d7a78643f69 ("crypto: ecrdsa - add EC-RDSA (GOST 34.10) algorithm")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Eric Biggers <ebiggers@google.com>
> > ---
> >  crypto/asymmetric_keys/public_key.c | 111 +++++++++++++++++++---------
> >  1 file changed, 76 insertions(+), 35 deletions(-)
> > 
> > diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c
> > index aba7113d86c76..a603ee8afdb8d 100644
> > --- a/crypto/asymmetric_keys/public_key.c
> > +++ b/crypto/asymmetric_keys/public_key.c
> > @@ -60,39 +60,83 @@ static void public_key_destroy(void *payload0, void *payload3)
> >  }
> >  
> >  /*
> > - * Determine the crypto algorithm name.
> > + * Given a public_key, and an encoding and hash_algo to be used for signing
> > + * and/or verification with that key, determine the name of the corresponding
> > + * akcipher algorithm.  Also check that encoding and hash_algo are allowed.
> >   */
> > -static
> > -int software_key_determine_akcipher(const char *encoding,
> > -				    const char *hash_algo,
> > -				    const struct public_key *pkey,
> > -				    char alg_name[CRYPTO_MAX_ALG_NAME])
> > +static int
> > +software_key_determine_akcipher(const struct public_key *pkey,
> > +				const char *encoding, const char *hash_algo,
> > +				char alg_name[CRYPTO_MAX_ALG_NAME])
> 
> Why is changing parameter order necessary?
> 

It's mentioned in the commit message.  It's obviously not necessary but this way
makes much more sense IMO.

- Eric

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

* Re: [PATCH] KEYS: asymmetric: enforce SM2 signature use pkey algo
  2022-02-21  1:49   ` Jarkko Sakkinen
@ 2022-02-21  2:43     ` Tianjia Zhang
  2022-02-21 20:17       ` Jarkko Sakkinen
  0 siblings, 1 reply; 21+ messages in thread
From: Tianjia Zhang @ 2022-02-21  2:43 UTC (permalink / raw)
  To: Jarkko Sakkinen
  Cc: Eric Biggers, Mimi Zohar, Vitaly Chikunov, Stefan Berger,
	Gilad Ben-Yossef, David Howells, Herbert Xu, David S. Miller,
	keyrings, linux-crypto, linux-integrity

Hi Jarkko,

On 2/21/22 9:49 AM, Jarkko Sakkinen wrote:
> On Mon, Feb 07, 2022 at 07:43:27PM +0800, Tianjia Zhang wrote:
>> The signature verification of SM2 needs to add the Za value and
>> recalculate sig->digest, which requires the detection of the pkey_algo
>> in public_key_verify_signature(). As Eric Biggers said, the pkey_algo
>> field in sig is attacker-controlled and should be use pkey->pkey_algo
>> instead of sig->pkey_algo, and secondly, if sig->pkey_algo is NULL, it
>> will also cause signature verification failure.
>>
>> The software_key_determine_akcipher() already forces the algorithms
>> are matched, so the SM3 algorithm is enforced in the SM2 signature,
>> although this has been checked, we still avoid using any algorithm
>> information in the signature as input.
>>
>> Reported-by: Eric Biggers <ebiggers@google.com>
>> Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
>> ---
>>   crypto/asymmetric_keys/public_key.c | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c
>> index a603ee8afdb8..ea9a5501f87e 100644
>> --- a/crypto/asymmetric_keys/public_key.c
>> +++ b/crypto/asymmetric_keys/public_key.c
>> @@ -309,7 +309,8 @@ static int cert_sig_digest_update(const struct public_key_signature *sig,
>>   	if (ret)
>>   		return ret;
>>   
>> -	tfm = crypto_alloc_shash(sig->hash_algo, 0, 0);
>> +	/* SM2 signatures always use the SM3 hash algorithm */
>> +	tfm = crypto_alloc_shash("sm3", 0, 0);
> 
> Why not simply fail when sig->hash_algo != "sm3"?
> 
> BR, Jarkko

This series of Eric's patch 2/2 has done this check.

Best regards,
Tianjia

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

* Re: [PATCH 2/2] KEYS: asymmetric: properly validate hash_algo and encoding
  2022-02-21  2:21     ` Eric Biggers
@ 2022-02-21 20:16       ` Jarkko Sakkinen
  0 siblings, 0 replies; 21+ messages in thread
From: Jarkko Sakkinen @ 2022-02-21 20:16 UTC (permalink / raw)
  To: Eric Biggers
  Cc: keyrings, David Howells, linux-crypto, linux-integrity,
	Stefan Berger, Gilad Ben-Yossef, Tianjia Zhang, Vitaly Chikunov,
	Mimi Zohar, stable

On Sun, Feb 20, 2022 at 06:21:36PM -0800, Eric Biggers wrote:
> On Mon, Feb 21, 2022 at 02:46:26AM +0100, Jarkko Sakkinen wrote:
> > On Mon, Jan 31, 2022 at 04:34:14PM -0800, Eric Biggers wrote:
> > > From: Eric Biggers <ebiggers@google.com>
> > > 
> > > It is insecure to allow arbitrary hash algorithms and signature
> > > encodings to be used with arbitrary signature algorithms.  Notably,
> > > ECDSA, ECRDSA, and SM2 all sign/verify raw hash values and don't
> > > disambiguate between different hash algorithms like RSA PKCS#1 v1.5
> > > padding does.  Therefore, they need to be restricted to certain sets of
> > > hash algorithms (ideally just one, but in practice small sets are used).
> > > Additionally, the encoding is an integral part of modern signature
> > > algorithms, and is not supposed to vary.
> > > 
> > > Therefore, tighten the checks of hash_algo and encoding done by
> > > software_key_determine_akcipher().
> > > 
> > > Also rearrange the parameters to software_key_determine_akcipher() to
> > > put the public_key first, as this is the most important parameter and it
> > > often determines everything else.
> > > 
> > > Fixes: 299f561a6693 ("x509: Add support for parsing x509 certs with ECDSA keys")
> > > Fixes: 215525639631 ("X.509: support OSCCA SM2-with-SM3 certificate verification")
> > > Fixes: 0d7a78643f69 ("crypto: ecrdsa - add EC-RDSA (GOST 34.10) algorithm")
> > > Cc: stable@vger.kernel.org
> > > Signed-off-by: Eric Biggers <ebiggers@google.com>
> > > ---
> > >  crypto/asymmetric_keys/public_key.c | 111 +++++++++++++++++++---------
> > >  1 file changed, 76 insertions(+), 35 deletions(-)
> > > 
> > > diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c
> > > index aba7113d86c76..a603ee8afdb8d 100644
> > > --- a/crypto/asymmetric_keys/public_key.c
> > > +++ b/crypto/asymmetric_keys/public_key.c
> > > @@ -60,39 +60,83 @@ static void public_key_destroy(void *payload0, void *payload3)
> > >  }
> > >  
> > >  /*
> > > - * Determine the crypto algorithm name.
> > > + * Given a public_key, and an encoding and hash_algo to be used for signing
> > > + * and/or verification with that key, determine the name of the corresponding
> > > + * akcipher algorithm.  Also check that encoding and hash_algo are allowed.
> > >   */
> > > -static
> > > -int software_key_determine_akcipher(const char *encoding,
> > > -				    const char *hash_algo,
> > > -				    const struct public_key *pkey,
> > > -				    char alg_name[CRYPTO_MAX_ALG_NAME])
> > > +static int
> > > +software_key_determine_akcipher(const struct public_key *pkey,
> > > +				const char *encoding, const char *hash_algo,
> > > +				char alg_name[CRYPTO_MAX_ALG_NAME])
> > 
> > Why is changing parameter order necessary?
> > 
> 
> It's mentioned in the commit message.  It's obviously not necessary but this way
> makes much more sense IMO.

Ah, so it is.

Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>

BR, Jarkko

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

* Re: [PATCH] KEYS: asymmetric: enforce SM2 signature use pkey algo
  2022-02-21  2:43     ` Tianjia Zhang
@ 2022-02-21 20:17       ` Jarkko Sakkinen
  0 siblings, 0 replies; 21+ messages in thread
From: Jarkko Sakkinen @ 2022-02-21 20:17 UTC (permalink / raw)
  To: Tianjia Zhang
  Cc: Eric Biggers, Mimi Zohar, Vitaly Chikunov, Stefan Berger,
	Gilad Ben-Yossef, David Howells, Herbert Xu, David S. Miller,
	keyrings, linux-crypto, linux-integrity

On Mon, Feb 21, 2022 at 10:43:39AM +0800, Tianjia Zhang wrote:
> Hi Jarkko,
> 
> On 2/21/22 9:49 AM, Jarkko Sakkinen wrote:
> > On Mon, Feb 07, 2022 at 07:43:27PM +0800, Tianjia Zhang wrote:
> > > The signature verification of SM2 needs to add the Za value and
> > > recalculate sig->digest, which requires the detection of the pkey_algo
> > > in public_key_verify_signature(). As Eric Biggers said, the pkey_algo
> > > field in sig is attacker-controlled and should be use pkey->pkey_algo
> > > instead of sig->pkey_algo, and secondly, if sig->pkey_algo is NULL, it
> > > will also cause signature verification failure.
> > > 
> > > The software_key_determine_akcipher() already forces the algorithms
> > > are matched, so the SM3 algorithm is enforced in the SM2 signature,
> > > although this has been checked, we still avoid using any algorithm
> > > information in the signature as input.
> > > 
> > > Reported-by: Eric Biggers <ebiggers@google.com>
> > > Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
> > > ---
> > >   crypto/asymmetric_keys/public_key.c | 6 +++---
> > >   1 file changed, 3 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c
> > > index a603ee8afdb8..ea9a5501f87e 100644
> > > --- a/crypto/asymmetric_keys/public_key.c
> > > +++ b/crypto/asymmetric_keys/public_key.c
> > > @@ -309,7 +309,8 @@ static int cert_sig_digest_update(const struct public_key_signature *sig,
> > >   	if (ret)
> > >   		return ret;
> > > -	tfm = crypto_alloc_shash(sig->hash_algo, 0, 0);
> > > +	/* SM2 signatures always use the SM3 hash algorithm */
> > > +	tfm = crypto_alloc_shash("sm3", 0, 0);
> > 
> > Why not simply fail when sig->hash_algo != "sm3"?
> > 
> > BR, Jarkko
> 
> This series of Eric's patch 2/2 has done this check.
> 
> Best regards,
> Tianjia

Hmm... So how does that make this legit?

BR, Jarkko

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

* Re: [PATCH 1/2] KEYS: asymmetric: enforce that sig algo matches key algo
  2022-02-21  1:43   ` Jarkko Sakkinen
@ 2022-03-04 19:26     ` Eric Biggers
  2022-03-05  5:51       ` Jarkko Sakkinen
  0 siblings, 1 reply; 21+ messages in thread
From: Eric Biggers @ 2022-03-04 19:26 UTC (permalink / raw)
  To: Jarkko Sakkinen
  Cc: David Howells, keyrings, linux-crypto, linux-integrity,
	Stefan Berger, Gilad Ben-Yossef, Tianjia Zhang, Vitaly Chikunov,
	Mimi Zohar, stable

On Mon, Feb 21, 2022 at 02:43:21AM +0100, Jarkko Sakkinen wrote:
> 
> Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
> 
> David, do you want to pick this?
> 

No response from David, so I think you need to take these.

- Eric

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

* Re: [PATCH 1/2] KEYS: asymmetric: enforce that sig algo matches key algo
  2022-03-04 19:26     ` Eric Biggers
@ 2022-03-05  5:51       ` Jarkko Sakkinen
  0 siblings, 0 replies; 21+ messages in thread
From: Jarkko Sakkinen @ 2022-03-05  5:51 UTC (permalink / raw)
  To: Eric Biggers
  Cc: David Howells, keyrings, linux-crypto, linux-integrity,
	Stefan Berger, Gilad Ben-Yossef, Tianjia Zhang, Vitaly Chikunov,
	Mimi Zohar, stable

On Fri, Mar 04, 2022 at 11:26:10AM -0800, Eric Biggers wrote:
> On Mon, Feb 21, 2022 at 02:43:21AM +0100, Jarkko Sakkinen wrote:
> > 
> > Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
> > 
> > David, do you want to pick this?
> > 
> 
> No response from David, so I think you need to take these.
> 
> - Eric

I did, they're applied now, thank you.

BR, Jarkko

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

end of thread, other threads:[~2022-03-05  5:52 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-01  0:34 [PATCH 0/2] Fix bugs in public_key_verify_signature() Eric Biggers
2022-02-01  0:34 ` [PATCH 1/2] KEYS: asymmetric: enforce that sig algo matches key algo Eric Biggers
2022-02-02  2:52   ` Vitaly Chikunov
2022-02-02  3:10     ` Eric Biggers
2022-02-02  3:22       ` Eric Biggers
2022-02-02  5:20       ` Vitaly Chikunov
2022-02-21  1:43   ` Jarkko Sakkinen
2022-03-04 19:26     ` Eric Biggers
2022-03-05  5:51       ` Jarkko Sakkinen
2022-02-01  0:34 ` [PATCH 2/2] KEYS: asymmetric: properly validate hash_algo and encoding Eric Biggers
2022-02-21  1:46   ` Jarkko Sakkinen
2022-02-21  2:21     ` Eric Biggers
2022-02-21 20:16       ` Jarkko Sakkinen
2022-02-01  2:38 ` [PATCH 0/2] Fix bugs in public_key_verify_signature() Stefan Berger
2022-02-07  7:45 ` Tianjia Zhang
2022-02-07 11:43 ` [PATCH] KEYS: asymmetric: enforce SM2 signature use pkey algo Tianjia Zhang
2022-02-08  5:35   ` Eric Biggers
2022-02-08  9:45     ` Tianjia Zhang
2022-02-21  1:49   ` Jarkko Sakkinen
2022-02-21  2:43     ` Tianjia Zhang
2022-02-21 20:17       ` Jarkko Sakkinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).