linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: Tong Zhang <ztong0001@gmail.com>
Cc: James Bottomley <jejb@linux.ibm.com>,
	Mimi Zohar <zohar@linux.ibm.com>,
	David Howells <dhowells@redhat.com>,
	James Morris <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	Sumit Garg <sumit.garg@linaro.org>,
	linux-integrity@vger.kernel.org, keyrings@vger.kernel.org,
	linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KEYS: trusted: fix crash when TPM/TEE are built as module
Date: Mon, 21 Feb 2022 00:05:57 +0100	[thread overview]
Message-ID: <YhLJVTQJ2o3fUCwy@iki.fi> (raw)
In-Reply-To: <20220204200342.48665-1-ztong0001@gmail.com>

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

      parent reply	other threads:[~2022-02-20 23:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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-20 23:05 ` Jarkko Sakkinen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YhLJVTQJ2o3fUCwy@iki.fi \
    --to=jarkko@kernel.org \
    --cc=dhowells@redhat.com \
    --cc=jejb@linux.ibm.com \
    --cc=jmorris@namei.org \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=serge@hallyn.com \
    --cc=sumit.garg@linaro.org \
    --cc=zohar@linux.ibm.com \
    --cc=ztong0001@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).