Skip to content

Commit c913dc9

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 c913dc9

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

linuxkm/lkcapi_rsa_glue.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
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+
#endif
33+
3034
#if !defined(NO_RSA)
3135
#if (defined(LINUXKM_LKCAPI_REGISTER_ALL) || \
3236
(defined(LINUXKM_LKCAPI_REGISTER_ALL_KCONFIG) && defined(CONFIG_CRYPTO_RSA))) && \
@@ -2347,6 +2351,14 @@ static int linuxkm_test_rsa_driver(const char * driver, int nbits)
23472351

23482352
memset(dec, 0, key_len);
23492353
ret = crypto_akcipher_decrypt(req);
2354+
#if defined(RHEL_RELEASE_CODE) && \
2355+
(RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 6))
2356+
if (ret == -ENOSYS) {
2357+
pr_info("info: skipping crypto_akcipher_decrypt (disabled by RHEL policy)\n");
2358+
test_rc = 0;
2359+
goto test_rsa_end;
2360+
}
2361+
#endif
23502362
if (ret) {
23512363
pr_err("error: crypto_akcipher_decrypt returned: %d\n", ret);
23522364
goto test_rsa_end;
@@ -2721,6 +2733,14 @@ static int linuxkm_test_pkcs1pad_driver(const char * driver, int nbits,
27212733
akcipher_request_set_crypt(req, &src, &dst, hash_len, key_len);
27222734

27232735
ret = crypto_akcipher_sign(req);
2736+
#if defined(RHEL_RELEASE_CODE) && \
2737+
(RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 6))
2738+
if (ret == -ENOSYS) {
2739+
pr_info("info: skipping crypto_akcipher_sign (disabled by RHEL policy)\n");
2740+
test_rc = 0;
2741+
goto test_pkcs1_end;
2742+
}
2743+
#endif
27242744
if (ret) {
27252745
pr_err("error: crypto_akcipher_sign returned: %d\n", ret);
27262746
test_rc = BAD_FUNC_ARG;
@@ -2847,6 +2867,14 @@ static int linuxkm_test_pkcs1pad_driver(const char * driver, int nbits,
28472867
}
28482868

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

0 commit comments

Comments
 (0)