Skip to content

Commit 002c77a

Browse files
jarodwilsonherbertx
authored andcommitted
crypto: fips - only panic on bad/missing crypto mod signatures
Per further discussion with NIST, the requirements for FIPS state that we only need to panic the system on failed kernel module signature checks for crypto subsystem modules. This moves the fips-mode-only module signature check out of the generic module loading code, into the crypto subsystem, at points where we can catch both algorithm module loads and mode module loads. At the same time, make CONFIG_CRYPTO_FIPS dependent on CONFIG_MODULE_SIG, as this is entirely necessary for FIPS mode. v2: remove extraneous blank line, perform checks in static inline function, drop no longer necessary fips.h include. CC: "David S. Miller" <davem@davemloft.net> CC: Rusty Russell <rusty@rustcorp.com.au> CC: Stephan Mueller <stephan.mueller@atsec.com> Signed-off-by: Jarod Wilson <jarod@redhat.com> Acked-by: Neil Horman <nhorman@tuxdriver.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 8f312d6 commit 002c77a

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

‎crypto/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ comment "Crypto core or helper"
2424
config CRYPTO_FIPS
2525
bool "FIPS 200 compliance"
2626
depends on (CRYPTO_ANSI_CPRNG || CRYTPO_DRBG) && !CRYPTO_MANAGER_DISABLE_TESTS
27+
depends on MODULE_SIG
2728
help
2829
This options enables the fips boot option which is
2930
required if you want to system to operate in a FIPS 200

‎crypto/algapi.c‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,20 @@ static inline int crypto_set_driver_name(struct crypto_alg *alg)
4141
return 0;
4242
}
4343

44+
static inline void crypto_check_module_sig(struct module *mod)
45+
{
46+
#ifdef CONFIG_CRYPTO_FIPS
47+
if (fips_enabled && mod && !mod->sig_ok)
48+
panic("Module %s signature verification failed in FIPS mode\n",
49+
mod->name);
50+
#endif
51+
return;
52+
}
53+
4454
static int crypto_check_alg(struct crypto_alg *alg)
4555
{
56+
crypto_check_module_sig(alg->cra_module);
57+
4658
if (alg->cra_alignmask & (alg->cra_alignmask + 1))
4759
return -EINVAL;
4860

@@ -430,6 +442,8 @@ int crypto_register_template(struct crypto_template *tmpl)
430442

431443
down_write(&crypto_alg_sem);
432444

445+
crypto_check_module_sig(tmpl->module);
446+
433447
list_for_each_entry(q, &crypto_template_list, list) {
434448
if (q == tmpl)
435449
goto out;

‎kernel/module.c‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
#include <linux/jump_label.h>
6161
#include <linux/pfn.h>
6262
#include <linux/bsearch.h>
63-
#include <linux/fips.h>
6463
#include <uapi/linux/module.h>
6564
#include "module-internal.h"
6665

@@ -2448,9 +2447,6 @@ static int module_sig_check(struct load_info *info)
24482447
}
24492448

24502449
/* Not having a signature is only an error if we're strict. */
2451-
if (err < 0 && fips_enabled)
2452-
panic("Module verification failed with error %d in FIPS mode\n",
2453-
err);
24542450
if (err == -ENOKEY && !sig_enforce)
24552451
err = 0;
24562452

0 commit comments

Comments
 (0)