Skip to content

Commit b53b17f

Browse files
committed
linuxkm: handle RHEL9 disabled akcipher sign/decrypt ops
RHEL9 kernels (9.6+) disable RSA signing and decryption in the kernel crypto API for security reasons (CVE-2023-6240). The kernel forcibly overwrites akcipher sign/decrypt callbacks to return -ENOSYS, regardless of what the driver provides. Commit 3709c35c in the RHEL kernel: "crypto: akcipher - Disable signing and decryption" This affects our self-tests which call crypto_akcipher_sign() and crypto_akcipher_decrypt(). On RHEL9, these operations return -ENOSYS even though our driver correctly implements them. Add compile-time checks for RHEL_RELEASE_CODE >= 9.6 to detect this scenario and skip the affected self-tests gracefully. The tests pass since the algorithms are registered correctly; the kernel simply refuses to execute sign/decrypt operations as a matter of policy. Note: encrypt and verify operations are unaffected and continue to be tested normally. Signed-off-by: Sameeh Jubran <[email protected]>
1 parent 0d44018 commit b53b17f

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

linuxkm/lkcapi_rsa_glue.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@
2727
#error lkcapi_rsa_glue.c included in non-LINUXKM_LKCAPI_REGISTER project.
2828
#endif
2929

30+
#ifdef RHEL_RELEASE_CODE
31+
#include <linux/rhel_versions.h>
32+
#elif
33+
#define RHEL_RELEASE_VERSION(a, b) (((a) << 8) + (b))
34+
#endif
35+
3036
#if !defined(NO_RSA)
3137
#if (defined(LINUXKM_LKCAPI_REGISTER_ALL) || \
3238
(defined(LINUXKM_LKCAPI_REGISTER_ALL_KCONFIG) && defined(CONFIG_CRYPTO_RSA))) && \
@@ -2347,6 +2353,14 @@ static int linuxkm_test_rsa_driver(const char * driver, int nbits)
23472353

23482354
memset(dec, 0, key_len);
23492355
ret = crypto_akcipher_decrypt(req);
2356+
#if defined(RHEL_RELEASE_CODE) && defined(RHEL_RELEASE_VERSION) && \
2357+
(RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 6))
2358+
if (ret == -ENOSYS) {
2359+
pr_info("info: skipping crypto_akcipher_decrypt (disabled by RHEL policy)\n");
2360+
test_rc = 0;
2361+
goto test_rsa_end;
2362+
}
2363+
#endif
23502364
if (ret) {
23512365
pr_err("error: crypto_akcipher_decrypt returned: %d\n", ret);
23522366
goto test_rsa_end;
@@ -2721,6 +2735,14 @@ static int linuxkm_test_pkcs1pad_driver(const char * driver, int nbits,
27212735
akcipher_request_set_crypt(req, &src, &dst, hash_len, key_len);
27222736

27232737
ret = crypto_akcipher_sign(req);
2738+
#if defined(RHEL_RELEASE_CODE) && defined(RHEL_RELEASE_VERSION) && \
2739+
(RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 6))
2740+
if (ret == -ENOSYS) {
2741+
pr_info("info: skipping crypto_akcipher_sign (disabled by RHEL policy)\n");
2742+
test_rc = 0;
2743+
goto test_pkcs1_end;
2744+
}
2745+
#endif
27242746
if (ret) {
27252747
pr_err("error: crypto_akcipher_sign returned: %d\n", ret);
27262748
test_rc = BAD_FUNC_ARG;
@@ -2847,6 +2869,14 @@ static int linuxkm_test_pkcs1pad_driver(const char * driver, int nbits,
28472869
}
28482870

28492871
ret = crypto_akcipher_decrypt(req);
2872+
#if defined(RHEL_RELEASE_CODE) && defined(RHEL_RELEASE_VERSION) && \
2873+
(RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 6))
2874+
if (ret == -ENOSYS) {
2875+
pr_info("info: skipping crypto_akcipher_decrypt (disabled by RHEL policy)\n");
2876+
test_rc = 0;
2877+
goto test_pkcs1_end;
2878+
}
2879+
#endif
28502880
if (ret) {
28512881
pr_err("error: crypto_akcipher_decrypt returned: %d\n", ret);
28522882
test_rc = BAD_FUNC_ARG;

0 commit comments

Comments
 (0)