Skip to content

Commit

Permalink
crypto: api - Move module sig ifdef into accessor function
Browse files Browse the repository at this point in the history
Currently we're hiding mod->sig_ok under an ifdef in open code.
This patch adds a module_sig_ok accessor function and removes that
ifdef.

Signed-off-by: Herbert Xu <[email protected]>
Acked-by: Rusty Russell <[email protected]>
  • Loading branch information
herbertx committed Apr 23, 2015
1 parent 43a9607 commit 59afdc7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 1 addition & 4 deletions crypto/algapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,9 @@ static inline int crypto_set_driver_name(struct crypto_alg *alg)

static inline void crypto_check_module_sig(struct module *mod)
{
#ifdef CONFIG_CRYPTO_FIPS
if (fips_enabled && mod && !mod->sig_ok)
if (fips_enabled && mod && !module_sig_ok(mod))
panic("Module %s signature verification failed in FIPS mode\n",
mod->name);
#endif
return;
}

static int crypto_check_alg(struct crypto_alg *alg)
Expand Down
12 changes: 12 additions & 0 deletions include/linux/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -655,4 +655,16 @@ static inline void module_bug_finalize(const Elf_Ehdr *hdr,
static inline void module_bug_cleanup(struct module *mod) {}
#endif /* CONFIG_GENERIC_BUG */

#ifdef CONFIG_MODULE_SIG
static inline bool module_sig_ok(struct module *module)
{
return module->sig_ok;
}
#else /* !CONFIG_MODULE_SIG */
static inline bool module_sig_ok(struct module *module)
{
return true;
}
#endif /* CONFIG_MODULE_SIG */

#endif /* _LINUX_MODULE_H */

0 comments on commit 59afdc7

Please sign in to comment.