Skip to content

Commit d2f819a

Browse files
committed
linuxkm/module_hooks.c and linuxkm/lkcapi_glue.c: check retval from WC_SIG_IGNORE_BEGIN().
1 parent e142a96 commit d2f819a

2 files changed

Lines changed: 44 additions & 16 deletions

File tree

linuxkm/lkcapi_glue.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,11 @@ static int linuxkm_lkcapi_register(void)
329329
return -EDEADLK;
330330
}
331331

332-
WC_SIG_IGNORE_BEGIN();
332+
if (WC_SIG_IGNORE_BEGIN() < 0) {
333+
ret = -ECANCELED;
334+
pr_err("ERROR: WC_SIG_IGNORE_BEGIN() failed.\n");
335+
goto out_without_sig_ignored;
336+
}
333337

334338
ret = linuxkm_lkcapi_sysfs_install();
335339
if (ret)
@@ -738,7 +742,10 @@ static int linuxkm_lkcapi_register(void)
738742

739743
out:
740744

741-
WC_SIG_IGNORE_END();
745+
(void)WC_SIG_IGNORE_END();
746+
747+
out_without_sig_ignored:
748+
742749
WOLFSSL_ATOMIC_STORE(linuxkm_lkcapi_registering_now, 0);
743750

744751
return ret;
@@ -759,7 +766,11 @@ static int linuxkm_lkcapi_unregister(void)
759766
return -EDEADLK;
760767
}
761768

762-
WC_SIG_IGNORE_BEGIN();
769+
if (WC_SIG_IGNORE_BEGIN() < 0) {
770+
ret = -ECANCELED;
771+
pr_err("ERROR: WC_SIG_IGNORE_BEGIN() failed.\n");
772+
goto out_without_sig_ignored;
773+
}
763774

764775
if (linuxkm_lkcapi_n_registered == 0) {
765776
ret = -ENOENT;
@@ -1010,7 +1021,10 @@ static int linuxkm_lkcapi_unregister(void)
10101021

10111022
out:
10121023

1013-
WC_SIG_IGNORE_END();
1024+
(void)WC_SIG_IGNORE_END();
1025+
1026+
out_without_sig_ignored:
1027+
10141028
WOLFSSL_ATOMIC_STORE(linuxkm_lkcapi_registering_now, 0);
10151029

10161030
return ret;

linuxkm/module_hooks.c

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -591,9 +591,12 @@ static int wolfssl_init(void)
591591
total_other_r = 0;
592592
#endif
593593

594-
WC_SIG_IGNORE_BEGIN();
595-
fipsEntry();
596-
WC_SIG_IGNORE_END();
594+
if (WC_SIG_IGNORE_BEGIN() >= 0) {
595+
fipsEntry();
596+
(void)WC_SIG_IGNORE_END();
597+
}
598+
else
599+
pr_err("ERROR: WC_SIG_IGNORE_BEGIN() failed.\n");
597600

598601
#if defined(HAVE_LINUXKM_PIE_SUPPORT) && defined(DEBUG_LINUXKM_PIE_SUPPORT)
599602
pr_info("FIPS-bounded relocation normalizations: text=%d, rodata=%d, rwdata=%d, bss=%d, other=%d\n",
@@ -700,9 +703,12 @@ static int wolfssl_init(void)
700703
* because wc_GetCastStatus_fips(FIPS_CAST_HMAC_SHA2_256) isn't available
701704
* anymore.
702705
*/
703-
WC_SIG_IGNORE_BEGIN();
704-
fipsEntry();
705-
WC_SIG_IGNORE_END();
706+
if (WC_SIG_IGNORE_BEGIN() >= 0) {
707+
fipsEntry();
708+
(void)WC_SIG_IGNORE_END();
709+
}
710+
else
711+
pr_err("ERROR: WC_SIG_IGNORE_BEGIN() failed.\n");
706712
ret = wolfCrypt_GetStatus_fips();
707713
if (ret != 0) {
708714
pr_err("ERROR: wolfCrypt_GetStatus_fips() after reset failed with code %d: %s\n", ret, wc_GetErrorString(ret));
@@ -1690,9 +1696,14 @@ static ssize_t FIPS_rerun_self_test_handler(struct kobject *kobj, struct kobj_at
16901696

16911697
pr_info("wolfCrypt: rerunning FIPS self-test on command.");
16921698

1693-
WC_SIG_IGNORE_BEGIN();
1694-
ret = wolfCrypt_IntegrityTest_fips();
1695-
WC_SIG_IGNORE_END();
1699+
if (WC_SIG_IGNORE_BEGIN() >= 0) {
1700+
ret = wolfCrypt_IntegrityTest_fips();
1701+
(void)WC_SIG_IGNORE_END();
1702+
}
1703+
else {
1704+
pr_err("ERROR: WC_SIG_IGNORE_BEGIN() failed.\n");
1705+
ret = -1;
1706+
}
16961707
if (ret != 0) {
16971708
pr_err("ERROR: wolfCrypt_IntegrityTest_fips: error %d", ret);
16981709
return -EINVAL;
@@ -1775,9 +1786,12 @@ static ssize_t FIPS_optest_trig_handler(struct kobject *kobj, struct kobj_attrib
17751786
* because wc_GetCastStatus_fips(FIPS_CAST_HMAC_SHA2_256) isn't available
17761787
* anymore.
17771788
*/
1778-
WC_SIG_IGNORE_BEGIN();
1779-
fipsEntry();
1780-
WC_SIG_IGNORE_END();
1789+
if (WC_SIG_IGNORE_BEGIN() >= 0) {
1790+
fipsEntry();
1791+
(void)WC_SIG_IGNORE_END();
1792+
}
1793+
else
1794+
pr_err("ERROR: WC_SIG_IGNORE_BEGIN() failed.\n");
17811795
ret = wolfCrypt_GetStatus_fips();
17821796
printf("Status indicator of library reload/powercycle: %d\n",
17831797
ret);

0 commit comments

Comments
 (0)