* [PATCH] KEYS: trusted: fix crash when TPM/TEE are built as module
@ 2022-02-04 20:03 Tong Zhang
2022-02-06 10:36 ` Ahmad Fatoum
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Tong Zhang @ 2022-02-04 20:03 UTC (permalink / raw)
To: James Bottomley, Jarkko Sakkinen, Mimi Zohar, David Howells,
James Morris, Serge E. Hallyn, Sumit Garg, linux-integrity,
keyrings, linux-security-module, linux-kernel
Cc: Tong Zhang
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: 5d0682be3189 ("KEYS: trusted: Add generic trusted keys framework")
Signed-off-by: Tong Zhang <ztong0001@gmail.com>
---
security/keys/trusted-keys/trusted_core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/security/keys/trusted-keys/trusted_core.c b/security/keys/trusted-keys/trusted_core.c
index d5c891d8d353..b3a3b2f2d4a4 100644
--- a/security/keys/trusted-keys/trusted_core.c
+++ b/security/keys/trusted-keys/trusted_core.c
@@ -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
};
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] KEYS: trusted: fix crash when TPM/TEE are built as module
2022-02-04 20:03 [PATCH] KEYS: trusted: fix crash when TPM/TEE are built as module Tong Zhang
@ 2022-02-06 10:36 ` Ahmad Fatoum
2022-02-07 23:12 ` Tong Zhang
2022-02-20 23:10 ` Jarkko Sakkinen
2022-02-08 19:15 ` kernel test robot
2022-02-20 23:05 ` Jarkko Sakkinen
2 siblings, 2 replies; 7+ messages in thread
From: Ahmad Fatoum @ 2022-02-06 10:36 UTC (permalink / raw)
To: Tong Zhang, James Bottomley, Jarkko Sakkinen, Mimi Zohar,
David Howells, James Morris, Serge E. Hallyn, Sumit Garg,
linux-integrity, keyrings, linux-security-module, linux-kernel,
Andreas Rammhold
Hello Tong,
On 04.02.22 21:03, Tong Zhang wrote:
> 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.
Jarkko reported picking up an equivalent fix two months ago:
https://lkml.kernel.org/keyrings/YadRAWbl2aiapf8l@iki.fi/
But it seems to have never made it to Linus.
Cheers,
Ahmad
>
> 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: 5d0682be3189 ("KEYS: trusted: Add generic trusted keys framework")
> Signed-off-by: Tong Zhang <ztong0001@gmail.com>
> ---
> security/keys/trusted-keys/trusted_core.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/security/keys/trusted-keys/trusted_core.c b/security/keys/trusted-keys/trusted_core.c
> index d5c891d8d353..b3a3b2f2d4a4 100644
> --- a/security/keys/trusted-keys/trusted_core.c
> +++ b/security/keys/trusted-keys/trusted_core.c
> @@ -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
> };
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] KEYS: trusted: fix crash when TPM/TEE are built as module
2022-02-06 10:36 ` Ahmad Fatoum
@ 2022-02-07 23:12 ` Tong Zhang
2022-02-20 23:10 ` Jarkko Sakkinen
1 sibling, 0 replies; 7+ messages in thread
From: Tong Zhang @ 2022-02-07 23:12 UTC (permalink / raw)
To: Ahmad Fatoum
Cc: James Bottomley, Jarkko Sakkinen, Mimi Zohar, David Howells,
James Morris, Serge E. Hallyn, Sumit Garg, linux-integrity,
keyrings, linux-security-module, open list, Andreas Rammhold
On Sun, Feb 6, 2022 at 2:36 AM Ahmad Fatoum <a.fatoum@pengutronix.de> wrote:
>
> Hello Tong,
>
> On 04.02.22 21:03, Tong Zhang wrote:
> > 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.
>
> Jarkko reported picking up an equivalent fix two months ago:
> https://lkml.kernel.org/keyrings/YadRAWbl2aiapf8l@iki.fi/
>
> But it seems to have never made it to Linus.
>
> Cheers,
> Ahmad
>
> >
> > 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: 5d0682be3189 ("KEYS: trusted: Add generic trusted keys framework")
> > Signed-off-by: Tong Zhang <ztong0001@gmail.com>
> > ---
> > security/keys/trusted-keys/trusted_core.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/security/keys/trusted-keys/trusted_core.c b/security/keys/trusted-keys/trusted_core.c
> > index d5c891d8d353..b3a3b2f2d4a4 100644
> > --- a/security/keys/trusted-keys/trusted_core.c
> > +++ b/security/keys/trusted-keys/trusted_core.c
> > @@ -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
> > };
>
>
> --
> Pengutronix e.K. | |
> Steuerwalder Str. 21 | http://www.pengutronix.de/ |
> 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Hi Ahmad,
Thanks for letting me know.
That fix looks good to me.
- Tong
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] KEYS: trusted: fix crash when TPM/TEE are built as module
2022-02-04 20:03 [PATCH] KEYS: trusted: fix crash when TPM/TEE are built as module Tong Zhang
@ 2022-02-08 19:15 ` kernel test robot
2022-02-08 19:15 ` kernel test robot
2022-02-20 23:05 ` Jarkko Sakkinen
2 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2022-02-08 19:15 UTC (permalink / raw)
To: Tong Zhang; +Cc: llvm, kbuild-all
Hi Tong,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on v5.17-rc2]
[also build test ERROR on next-20220208]
[cannot apply to jmorris-security/next-testing]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Tong-Zhang/KEYS-trusted-fix-crash-when-TPM-TEE-are-built-as-module/20220205-040706
base: 26291c54e111ff6ba87a164d85d4a4e134b7315c
config: i386-randconfig-a011 (https://download.01.org/0day-ci/archive/20220209/202202090354.jnH19acv-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project e8bff9ae54a55b4dbfeb6ba55f723abbd81bf494)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/1f9dab49ae11af2bde1b057f7104ded0714ae7dd
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Tong-Zhang/KEYS-trusted-fix-crash-when-TPM-TEE-are-built-as-module/20220205-040706
git checkout 1f9dab49ae11af2bde1b057f7104ded0714ae7dd
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
>> ld.lld: error: undefined symbol: trusted_key_tee_ops
>>> referenced by trusted_core.c
>>> keys/trusted-keys/trusted_core.o:(trusted_key_sources) in archive security/built-in.a
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] KEYS: trusted: fix crash when TPM/TEE are built as module
@ 2022-02-08 19:15 ` kernel test robot
0 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2022-02-08 19:15 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 1997 bytes --]
Hi Tong,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on v5.17-rc2]
[also build test ERROR on next-20220208]
[cannot apply to jmorris-security/next-testing]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Tong-Zhang/KEYS-trusted-fix-crash-when-TPM-TEE-are-built-as-module/20220205-040706
base: 26291c54e111ff6ba87a164d85d4a4e134b7315c
config: i386-randconfig-a011 (https://download.01.org/0day-ci/archive/20220209/202202090354.jnH19acv-lkp(a)intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project e8bff9ae54a55b4dbfeb6ba55f723abbd81bf494)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/1f9dab49ae11af2bde1b057f7104ded0714ae7dd
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Tong-Zhang/KEYS-trusted-fix-crash-when-TPM-TEE-are-built-as-module/20220205-040706
git checkout 1f9dab49ae11af2bde1b057f7104ded0714ae7dd
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
>> ld.lld: error: undefined symbol: trusted_key_tee_ops
>>> referenced by trusted_core.c
>>> keys/trusted-keys/trusted_core.o:(trusted_key_sources) in archive security/built-in.a
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] KEYS: trusted: fix crash when TPM/TEE are built as module
2022-02-04 20:03 [PATCH] KEYS: trusted: fix crash when TPM/TEE are built as module Tong Zhang
2022-02-06 10:36 ` Ahmad Fatoum
2022-02-08 19:15 ` kernel test robot
@ 2022-02-20 23:05 ` Jarkko Sakkinen
2 siblings, 0 replies; 7+ messages in thread
From: Jarkko Sakkinen @ 2022-02-20 23:05 UTC (permalink / raw)
To: Tong Zhang
Cc: James Bottomley, Mimi Zohar, David Howells, James Morris,
Serge E. Hallyn, Sumit Garg, linux-integrity, keyrings,
linux-security-module, linux-kernel
On Fri, Feb 04, 2022 at 12:03:42PM -0800, Tong Zhang wrote:
> 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: 5d0682be3189 ("KEYS: trusted: Add generic trusted keys framework")
> Signed-off-by: Tong Zhang <ztong0001@gmail.com>
> ---
> security/keys/trusted-keys/trusted_core.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/security/keys/trusted-keys/trusted_core.c b/security/keys/trusted-keys/trusted_core.c
> index d5c891d8d353..b3a3b2f2d4a4 100644
> --- a/security/keys/trusted-keys/trusted_core.c
> +++ b/security/keys/trusted-keys/trusted_core.c
> @@ -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
> };
> --
> 2.25.1
>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
BR, Jarkko
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] KEYS: trusted: fix crash when TPM/TEE are built as module
2022-02-06 10:36 ` Ahmad Fatoum
2022-02-07 23:12 ` Tong Zhang
@ 2022-02-20 23:10 ` Jarkko Sakkinen
1 sibling, 0 replies; 7+ messages in thread
From: Jarkko Sakkinen @ 2022-02-20 23:10 UTC (permalink / raw)
To: Ahmad Fatoum
Cc: Tong Zhang, James Bottomley, Mimi Zohar, David Howells,
James Morris, Serge E. Hallyn, Sumit Garg, linux-integrity,
keyrings, linux-security-module, linux-kernel, Andreas Rammhold
On Sun, Feb 06, 2022 at 11:36:48AM +0100, Ahmad Fatoum wrote:
> Hello Tong,
>
> On 04.02.22 21:03, Tong Zhang wrote:
> > 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.
>
> Jarkko reported picking up an equivalent fix two months ago:
> https://lkml.kernel.org/keyrings/YadRAWbl2aiapf8l@iki.fi/
>
> But it seems to have never made it to Linus.
Sorry, was not done purposely. I pushed the original fix.
BR, Jarkko
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-02-20 23:09 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-04 20:03 [PATCH] KEYS: trusted: fix crash when TPM/TEE are built as module Tong Zhang
2022-02-06 10:36 ` Ahmad Fatoum
2022-02-07 23:12 ` Tong Zhang
2022-02-20 23:10 ` Jarkko Sakkinen
2022-02-08 19:15 ` kernel test robot
2022-02-08 19:15 ` kernel test robot
2022-02-20 23:05 ` Jarkko Sakkinen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.