Skip to content

Commit 1075ce8

Browse files
authored
Merge pull request #8727 from douzzer/20250501-linuxkm-ecdsa-workaround
20250501-linuxkm-ecdsa-workaround
2 parents aa50cfc + fea5694 commit 1075ce8

File tree

5 files changed

+28
-17
lines changed

5 files changed

+28
-17
lines changed

linuxkm/lkcapi_dh_glue.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2821,23 +2821,23 @@ static int linuxkm_test_kpp_driver(const char * driver,
28212821
if (IS_ERR(tfm)) {
28222822
pr_err("error: allocating kpp algorithm %s failed: %ld\n",
28232823
driver, PTR_ERR(tfm));
2824-
tfm = NULL;
28252824
if (PTR_ERR(tfm) == -ENOMEM)
28262825
test_rc = MEMORY_E;
28272826
else
28282827
test_rc = BAD_FUNC_ARG;
2828+
tfm = NULL;
28292829
goto test_kpp_end;
28302830
}
28312831

28322832
req = kpp_request_alloc(tfm, GFP_KERNEL);
28332833
if (IS_ERR(req)) {
28342834
pr_err("error: allocating kpp request %s failed\n",
28352835
driver);
2836-
req = NULL;
28372836
if (PTR_ERR(req) == -ENOMEM)
28382837
test_rc = MEMORY_E;
28392838
else
28402839
test_rc = BAD_FUNC_ARG;
2840+
req = NULL;
28412841
goto test_kpp_end;
28422842
}
28432843

linuxkm/lkcapi_ecdh_glue.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -804,23 +804,23 @@ static int linuxkm_test_ecdh_nist_driver(const char * driver,
804804
if (IS_ERR(tfm)) {
805805
pr_err("error: allocating kpp algorithm %s failed: %ld\n",
806806
driver, PTR_ERR(tfm));
807-
tfm = NULL;
808807
if (PTR_ERR(tfm) == -ENOMEM)
809808
test_rc = MEMORY_E;
810809
else
811810
test_rc = BAD_FUNC_ARG;
811+
tfm = NULL;
812812
goto test_ecdh_nist_end;
813813
}
814814

815815
req = kpp_request_alloc(tfm, GFP_KERNEL);
816816
if (IS_ERR(req)) {
817817
pr_err("error: allocating kpp request %s failed\n",
818818
driver);
819-
req = NULL;
820819
if (PTR_ERR(req) == -ENOMEM)
821820
test_rc = MEMORY_E;
822821
else
823822
test_rc = BAD_FUNC_ARG;
823+
req = NULL;
824824
goto test_ecdh_nist_end;
825825
}
826826

linuxkm/lkcapi_ecdsa_glue.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -680,23 +680,23 @@ static int linuxkm_test_ecdsa_nist_driver(const char * driver,
680680
if (IS_ERR(tfm)) {
681681
pr_err("error: allocating akcipher algorithm %s failed: %ld\n",
682682
driver, PTR_ERR(tfm));
683-
tfm = NULL;
684683
if (PTR_ERR(tfm) == -ENOMEM)
685684
test_rc = MEMORY_E;
686685
else
687686
test_rc = BAD_FUNC_ARG;
687+
tfm = NULL;
688688
goto test_ecdsa_nist_end;
689689
}
690690

691691
req = akcipher_request_alloc(tfm, GFP_KERNEL);
692692
if (IS_ERR(req)) {
693693
pr_err("error: allocating akcipher request %s failed\n",
694694
driver);
695-
req = NULL;
696695
if (PTR_ERR(req) == -ENOMEM)
697696
test_rc = MEMORY_E;
698697
else
699698
test_rc = BAD_FUNC_ARG;
699+
req = NULL;
700700
goto test_ecdsa_nist_end;
701701
}
702702

linuxkm/lkcapi_glue.c

+20-9
Original file line numberDiff line numberDiff line change
@@ -238,15 +238,6 @@ WC_MAYBE_UNUSED static int check_shash_driver_masking(struct crypto_shash *tfm,
238238
* extra checks on kernel version, and ecc sizes.
239239
*/
240240
#if defined (LINUXKM_LKCAPI_REGISTER_ECDSA)
241-
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0) && \
242-
defined(CONFIG_CRYPTO_FIPS) && defined(CONFIG_CRYPTO_MANAGER)
243-
/*
244-
* note: ecdsa was not recognized as fips_allowed before linux v6.3
245-
* in kernel crypto/testmgr.c, and will not pass the tests.
246-
*/
247-
#undef LINUXKM_LKCAPI_REGISTER_ECDSA
248-
#endif /* linux < 6.3.0 && CONFIG_CRYPTO_FIPS && CONFIG_CRYPTO_MANAGER */
249-
250241
#if (defined(HAVE_ECC192) || defined(HAVE_ALL_CURVES)) && \
251242
ECC_MIN_KEY_SZ <= 192 && !defined(CONFIG_CRYPTO_FIPS)
252243
/* only register p192 if specifically enabled, and if not fips. */
@@ -562,6 +553,18 @@ static int linuxkm_lkcapi_register(void)
562553
#endif
563554

564555
#ifdef LINUXKM_LKCAPI_REGISTER_ECDSA
556+
557+
#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0)) && \
558+
defined(HAVE_FIPS) && defined(CONFIG_CRYPTO_FIPS) && \
559+
defined(CONFIG_CRYPTO_MANAGER) && \
560+
!defined(CONFIG_CRYPTO_MANAGER_DISABLE_TESTS)
561+
/*
562+
* ecdsa was not recognized as fips_allowed before linux v6.3
563+
* in kernel crypto/testmgr.c.
564+
*/
565+
fips_enabled = 0;
566+
#endif
567+
565568
#if defined(LINUXKM_ECC192)
566569
REGISTER_ALG(ecdsa_nist_p192, akcipher,
567570
linuxkm_test_ecdsa_nist_p192);
@@ -577,6 +580,14 @@ static int linuxkm_lkcapi_register(void)
577580
REGISTER_ALG(ecdsa_nist_p521, akcipher,
578581
linuxkm_test_ecdsa_nist_p521);
579582
#endif /* HAVE_ECC521 */
583+
584+
#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0)) && \
585+
defined(HAVE_FIPS) && defined(CONFIG_CRYPTO_FIPS) && \
586+
defined(CONFIG_CRYPTO_MANAGER) && \
587+
!defined(CONFIG_CRYPTO_MANAGER_DISABLE_TESTS)
588+
fips_enabled = 1;
589+
#endif
590+
580591
#endif /* LINUXKM_LKCAPI_REGISTER_ECDSA */
581592

582593
#ifdef LINUXKM_LKCAPI_REGISTER_ECDH

linuxkm/lkcapi_rsa_glue.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1653,23 +1653,23 @@ static int linuxkm_test_pkcs1_driver(const char * driver, int nbits,
16531653
if (IS_ERR(tfm)) {
16541654
pr_err("error: allocating akcipher algorithm %s failed: %ld\n",
16551655
driver, PTR_ERR(tfm));
1656-
tfm = NULL;
16571656
if (PTR_ERR(tfm) == -ENOMEM)
16581657
test_rc = MEMORY_E;
16591658
else
16601659
test_rc = BAD_FUNC_ARG;
1660+
tfm = NULL;
16611661
goto test_pkcs1_end;
16621662
}
16631663

16641664
req = akcipher_request_alloc(tfm, GFP_KERNEL);
16651665
if (IS_ERR(req)) {
16661666
pr_err("error: allocating akcipher request %s failed\n",
16671667
driver);
1668-
req = NULL;
16691668
if (PTR_ERR(req) == -ENOMEM)
16701669
test_rc = MEMORY_E;
16711670
else
16721671
test_rc = BAD_FUNC_ARG;
1672+
req = NULL;
16731673
goto test_pkcs1_end;
16741674
}
16751675

0 commit comments

Comments
 (0)