Skip to content

Commit

Permalink
KEYS: trusted: fix crash when TPM/TEE are built as module
Browse files Browse the repository at this point in the history
when TCG_TPM and TEE are built as module, trusted_key_sources will be an
empty array, loading it won't do what it is supposed to do and unloading
it will cause kernel crash.

To reproduce:
$ modprobe trusted
$ modprobe -r trusted

[  173.749423] Unable to handle kernel NULL pointer dereference at virtual address 00000000
[  173.755268] Backtrace:
[  173.755378]  cleanup_trusted [trusted] from sys_delete_module+0x15c/0x22c
[  173.755589]  sys_delete_module from ret_fast_syscall+0x0/0x1c

To fix this issue, we also need to check CONFIG_TCG_TPM_MODULE and
CONFIG_TEE_MODULE.

Fixes: 5d0682b ("KEYS: trusted: Add generic trusted keys framework")
Signed-off-by: Tong Zhang <ztong0001@gmail.com>
  • Loading branch information
lzto authored and intel-lab-lkp committed Feb 4, 2022
1 parent 26291c5 commit 1f9dab4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions security/keys/trusted-keys/trusted_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ module_param_named(source, trusted_key_source, charp, 0);
MODULE_PARM_DESC(source, "Select trusted keys source (tpm or tee)");

static const struct trusted_key_source trusted_key_sources[] = {
#if defined(CONFIG_TCG_TPM)
#if defined(CONFIG_TCG_TPM) || defined(CONFIG_TCG_TPM_MODULE)
{ "tpm", &trusted_key_tpm_ops },
#endif
#if defined(CONFIG_TEE)
#if defined(CONFIG_TEE) || defined(CONFIG_TEE_MODULE)
{ "tee", &trusted_key_tee_ops },
#endif
};
Expand Down

0 comments on commit 1f9dab4

Please sign in to comment.