public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: ecrdsa - Fix module auto-load on add_key
@ 2024-03-18  0:42 Vitaly Chikunov
  2024-03-21 14:38 ` Stefan Berger
  2024-03-28 10:55 ` Herbert Xu
  0 siblings, 2 replies; 3+ messages in thread
From: Vitaly Chikunov @ 2024-03-18  0:42 UTC (permalink / raw)
  To: Herbert Xu, linux-crypto, linux-kernel; +Cc: Paul Wolneykien, David S. Miller

Add module alias with the algorithm cra_name similar to what we have for
RSA-related and other algorithms.

The kernel attempts to modprobe asymmetric algorithms using the names
"crypto-$cra_name" and "crypto-$cra_name-all." However, since these
aliases are currently missing, the modules are not loaded. For instance,
when using the `add_key` function, the hash algorithm is typically
loaded automatically, but the asymmetric algorithm is not.

Steps to test:

1. Cert is generated usings ima-evm-utils test suite with
   `gen-keys.sh`, example cert is provided below:

  $ base64 -d >test-gost2012_512-A.cer <<EOF
  MIIB/DCCAWagAwIBAgIUK8+whWevr3FFkSdU9GLDAM7ure8wDAYIKoUDBwEBAwMFADARMQ8wDQYD
  VQQDDAZDQSBLZXkwIBcNMjIwMjAxMjIwOTQxWhgPMjA4MjEyMDUyMjA5NDFaMBExDzANBgNVBAMM
  BkNBIEtleTCBoDAXBggqhQMHAQEBAjALBgkqhQMHAQIBAgEDgYQABIGALXNrTJGgeErBUOov3Cfo
  IrHF9fcj8UjzwGeKCkbCcINzVUbdPmCopeJRHDJEvQBX1CQUPtlwDv6ANjTTRoq5nCk9L5PPFP1H
  z73JIXHT0eRBDVoWy0cWDRz1mmQlCnN2HThMtEloaQI81nTlKZOcEYDtDpi5WODmjEeRNQJMdqCj
  UDBOMAwGA1UdEwQFMAMBAf8wHQYDVR0OBBYEFCwfOITMbE9VisW1i2TYeu1tAo5QMB8GA1UdIwQY
  MBaAFCwfOITMbE9VisW1i2TYeu1tAo5QMAwGCCqFAwcBAQMDBQADgYEAmBfJCMTdC0/NSjz4BBiQ
  qDIEjomO7FEHYlkX5NGulcF8FaJW2jeyyXXtbpnub1IQ8af1KFIpwoS2e93LaaofxpWlpQLlju6m
  KYLOcO4xK3Whwa2hBAz9YbpUSFjvxnkS2/jpH2MsOSXuUEeCruG/RkHHB3ACef9umG6HCNQuAPY=
  EOF

2. Optionally, trace module requests with: trace-cmd stream -e module &

3. Trigger add_key call for the cert:

  # keyctl padd asymmetric "" @u <test-gost2012_512-A.cer
  939910969
  # lsmod | head -3
  Module                  Size  Used by
  ecrdsa_generic         16384  0
  streebog_generic       28672  0

Repored-by: Paul Wolneykien <manowar@altlinux.org>
Cc: stable@vger.kernel.org
Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
---
 crypto/ecrdsa.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/crypto/ecrdsa.c b/crypto/ecrdsa.c
index f3c6b5e15e75..3811f3805b5d 100644
--- a/crypto/ecrdsa.c
+++ b/crypto/ecrdsa.c
@@ -294,4 +294,5 @@ module_exit(ecrdsa_mod_fini);
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Vitaly Chikunov <vt@altlinux.org>");
 MODULE_DESCRIPTION("EC-RDSA generic algorithm");
+MODULE_ALIAS_CRYPTO("ecrdsa");
 MODULE_ALIAS_CRYPTO("ecrdsa-generic");
-- 
2.42.1


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

* Re: [PATCH] crypto: ecrdsa - Fix module auto-load on add_key
  2024-03-18  0:42 [PATCH] crypto: ecrdsa - Fix module auto-load on add_key Vitaly Chikunov
@ 2024-03-21 14:38 ` Stefan Berger
  2024-03-28 10:55 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Berger @ 2024-03-21 14:38 UTC (permalink / raw)
  To: Vitaly Chikunov, Herbert Xu, linux-crypto, linux-kernel
  Cc: Paul Wolneykien, David S. Miller



On 3/17/24 20:42, Vitaly Chikunov wrote:
> Add module alias with the algorithm cra_name similar to what we have for
> RSA-related and other algorithms.
> 
> The kernel attempts to modprobe asymmetric algorithms using the names
> "crypto-$cra_name" and "crypto-$cra_name-all." However, since these
> aliases are currently missing, the modules are not loaded. For instance,
> when using the `add_key` function, the hash algorithm is typically
> loaded automatically, but the asymmetric algorithm is not.
> 
> Steps to test:
> 
> 1. Cert is generated usings ima-evm-utils test suite with
>     `gen-keys.sh`, example cert is provided below:
> 
>    $ base64 -d >test-gost2012_512-A.cer <<EOF
>    MIIB/DCCAWagAwIBAgIUK8+whWevr3FFkSdU9GLDAM7ure8wDAYIKoUDBwEBAwMFADARMQ8wDQYD
>    VQQDDAZDQSBLZXkwIBcNMjIwMjAxMjIwOTQxWhgPMjA4MjEyMDUyMjA5NDFaMBExDzANBgNVBAMM
>    BkNBIEtleTCBoDAXBggqhQMHAQEBAjALBgkqhQMHAQIBAgEDgYQABIGALXNrTJGgeErBUOov3Cfo
>    IrHF9fcj8UjzwGeKCkbCcINzVUbdPmCopeJRHDJEvQBX1CQUPtlwDv6ANjTTRoq5nCk9L5PPFP1H
>    z73JIXHT0eRBDVoWy0cWDRz1mmQlCnN2HThMtEloaQI81nTlKZOcEYDtDpi5WODmjEeRNQJMdqCj
>    UDBOMAwGA1UdEwQFMAMBAf8wHQYDVR0OBBYEFCwfOITMbE9VisW1i2TYeu1tAo5QMB8GA1UdIwQY
>    MBaAFCwfOITMbE9VisW1i2TYeu1tAo5QMAwGCCqFAwcBAQMDBQADgYEAmBfJCMTdC0/NSjz4BBiQ
>    qDIEjomO7FEHYlkX5NGulcF8FaJW2jeyyXXtbpnub1IQ8af1KFIpwoS2e93LaaofxpWlpQLlju6m
>    KYLOcO4xK3Whwa2hBAz9YbpUSFjvxnkS2/jpH2MsOSXuUEeCruG/RkHHB3ACef9umG6HCNQuAPY=
>    EOF
> 
> 2. Optionally, trace module requests with: trace-cmd stream -e module &
> 
> 3. Trigger add_key call for the cert:
> 
>    # keyctl padd asymmetric "" @u <test-gost2012_512-A.cer
>    939910969
>    # lsmod | head -3
>    Module                  Size  Used by
>    ecrdsa_generic         16384  0
>    streebog_generic       28672  0
> 
> Repored-by: Paul Wolneykien <manowar@altlinux.org>
> Cc: stable@vger.kernel.org
> Signed-off-by: Vitaly Chikunov <vt@altlinux.org>

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

> ---
>   crypto/ecrdsa.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/crypto/ecrdsa.c b/crypto/ecrdsa.c
> index f3c6b5e15e75..3811f3805b5d 100644
> --- a/crypto/ecrdsa.c
> +++ b/crypto/ecrdsa.c
> @@ -294,4 +294,5 @@ module_exit(ecrdsa_mod_fini);
>   MODULE_LICENSE("GPL");
>   MODULE_AUTHOR("Vitaly Chikunov <vt@altlinux.org>");
>   MODULE_DESCRIPTION("EC-RDSA generic algorithm");
> +MODULE_ALIAS_CRYPTO("ecrdsa");
>   MODULE_ALIAS_CRYPTO("ecrdsa-generic");

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

* Re: [PATCH] crypto: ecrdsa - Fix module auto-load on add_key
  2024-03-18  0:42 [PATCH] crypto: ecrdsa - Fix module auto-load on add_key Vitaly Chikunov
  2024-03-21 14:38 ` Stefan Berger
@ 2024-03-28 10:55 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2024-03-28 10:55 UTC (permalink / raw)
  To: Vitaly Chikunov
  Cc: linux-crypto, linux-kernel, Paul Wolneykien, David S. Miller

On Mon, Mar 18, 2024 at 03:42:40AM +0300, Vitaly Chikunov wrote:
> Add module alias with the algorithm cra_name similar to what we have for
> RSA-related and other algorithms.
> 
> The kernel attempts to modprobe asymmetric algorithms using the names
> "crypto-$cra_name" and "crypto-$cra_name-all." However, since these
> aliases are currently missing, the modules are not loaded. For instance,
> when using the `add_key` function, the hash algorithm is typically
> loaded automatically, but the asymmetric algorithm is not.
> 
> Steps to test:
> 
> 1. Cert is generated usings ima-evm-utils test suite with
>    `gen-keys.sh`, example cert is provided below:
> 
>   $ base64 -d >test-gost2012_512-A.cer <<EOF
>   MIIB/DCCAWagAwIBAgIUK8+whWevr3FFkSdU9GLDAM7ure8wDAYIKoUDBwEBAwMFADARMQ8wDQYD
>   VQQDDAZDQSBLZXkwIBcNMjIwMjAxMjIwOTQxWhgPMjA4MjEyMDUyMjA5NDFaMBExDzANBgNVBAMM
>   BkNBIEtleTCBoDAXBggqhQMHAQEBAjALBgkqhQMHAQIBAgEDgYQABIGALXNrTJGgeErBUOov3Cfo
>   IrHF9fcj8UjzwGeKCkbCcINzVUbdPmCopeJRHDJEvQBX1CQUPtlwDv6ANjTTRoq5nCk9L5PPFP1H
>   z73JIXHT0eRBDVoWy0cWDRz1mmQlCnN2HThMtEloaQI81nTlKZOcEYDtDpi5WODmjEeRNQJMdqCj
>   UDBOMAwGA1UdEwQFMAMBAf8wHQYDVR0OBBYEFCwfOITMbE9VisW1i2TYeu1tAo5QMB8GA1UdIwQY
>   MBaAFCwfOITMbE9VisW1i2TYeu1tAo5QMAwGCCqFAwcBAQMDBQADgYEAmBfJCMTdC0/NSjz4BBiQ
>   qDIEjomO7FEHYlkX5NGulcF8FaJW2jeyyXXtbpnub1IQ8af1KFIpwoS2e93LaaofxpWlpQLlju6m
>   KYLOcO4xK3Whwa2hBAz9YbpUSFjvxnkS2/jpH2MsOSXuUEeCruG/RkHHB3ACef9umG6HCNQuAPY=
>   EOF
> 
> 2. Optionally, trace module requests with: trace-cmd stream -e module &
> 
> 3. Trigger add_key call for the cert:
> 
>   # keyctl padd asymmetric "" @u <test-gost2012_512-A.cer
>   939910969
>   # lsmod | head -3
>   Module                  Size  Used by
>   ecrdsa_generic         16384  0
>   streebog_generic       28672  0
> 
> Repored-by: Paul Wolneykien <manowar@altlinux.org>
> Cc: stable@vger.kernel.org
> Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
> ---
>  crypto/ecrdsa.c | 1 +
>  1 file changed, 1 insertion(+)

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] 3+ messages in thread

end of thread, other threads:[~2024-03-28 10:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-18  0:42 [PATCH] crypto: ecrdsa - Fix module auto-load on add_key Vitaly Chikunov
2024-03-21 14:38 ` Stefan Berger
2024-03-28 10:55 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox