public inbox for linux-integrity@vger.kernel.org
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: Peter Huewe <peterhuewe@gmx.de>, Jason Gunthorpe <jgg@ziepe.ca>,
	Mario Limonciello <mario.limonciello@amd.com>,
	"Jason A. Donenfeld" <Jason@zx2c4.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Martin Dimov <martin@dmarto.com>,
	linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tpm: Add !tpm_amd_is_rng_defective() to the hwrng_unregister() call site
Date: Mon, 24 Apr 2023 16:06:01 +0300	[thread overview]
Message-ID: <2772fde600710b99d482edee903f30bd87ea9aa8.camel@kernel.org> (raw)
In-Reply-To: <20230423154958.805992-1-jarkko@kernel.org>

On Sun, 2023-04-23 at 18:49 +0300, Jarkko Sakkinen wrote:
> The following crash was reported:
> 
> [ 1950.279393] list_del corruption, ffff99560d485790->next is NULL
> [ 1950.279400] ------------[ cut here ]------------
> [ 1950.279401] kernel BUG at lib/list_debug.c:49!
> [ 1950.279405] invalid opcode: 0000 [#1] PREEMPT SMP NOPTI
> [ 1950.279407] CPU: 11 PID: 5886 Comm: modprobe Tainted: G O 6.2.8_1 #1
> [ 1950.279409] Hardware name: Gigabyte Technology Co., Ltd. B550M AORUS PRO-P/B550M AORUS PRO-P,
> BIOS F15c 05/11/2022
> [ 1950.279410] RIP: 0010:__list_del_entry_valid+0x59/0xc0
> [ 1950.279415] Code: 48 8b 01 48 39 f8 75 5a 48 8b 72 08 48 39 c6 75 65 b8 01 00 00 00 c3 cc cc cc
> cc 48 89 fe 48 c7 c7 08 a8 13 9e e8 b7 0a bc ff <0f> 0b 48 89 fe 48 c7 c7 38 a8 13 9e e8 a6 0a bc
> ff 0f 0b 48 89 fe
> [ 1950.279416] RSP: 0018:ffffa96d05647e08 EFLAGS: 00010246
> [ 1950.279418] RAX: 0000000000000033 RBX: ffff99560d485750 RCX: 0000000000000000
> [ 1950.279419] RDX: 0000000000000000 RSI: ffffffff9e107c59 RDI: 00000000ffffffff
> [ 1950.279420] RBP: ffffffffc19c5168 R08: 0000000000000000 R09: ffffa96d05647cc8
> [ 1950.279421] R10: 0000000000000003 R11: ffffffff9ea2a568 R12: 0000000000000000
> [ 1950.279422] R13: ffff99560140a2e0 R14: ffff99560127d2e0 R15: 0000000000000000
> [ 1950.279422] FS: 00007f67da795380(0000) GS:ffff995d1f0c0000(0000) knlGS:0000000000000000
> [ 1950.279424] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [ 1950.279424] CR2: 00007f67da7e65c0 CR3: 00000001feed2000 CR4: 0000000000750ee0
> [ 1950.279426] PKRU: 55555554
> [ 1950.279426] Call Trace:
> [ 1950.279428] <TASK>
> [ 1950.279430] hwrng_unregister+0x28/0xe0 [rng_core]
> [ 1950.279436] tpm_chip_unregister+0xd5/0xf0 [tpm]
> 
> Add the forgotten !tpm_amd_is_rng_defective() invariant to the
> hwrng_unregister() call site inside tpm_chip_unregister().
> 
> Reported-by: Martin Dimov <martin@dmarto.com>
> Link: https://lore.kernel.org/linux-integrity/3d1d7e9dbfb8c96125bc93b6b58b90a7@dmarto.com/
> Fixes: f1324bbc4011 ("tpm: disable hwrng for fTPM on some AMD designs")
> Fixes: b006c439d58d ("hwrng: core - start hwrng kthread also for untrusted sources")
> Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
> ---
>  drivers/char/tpm/tpm-chip.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
> index 33319a78767f..6fdfa65a00c3 100644
> --- a/drivers/char/tpm/tpm-chip.c
> +++ b/drivers/char/tpm/tpm-chip.c
> @@ -692,7 +692,8 @@ EXPORT_SYMBOL_GPL(tpm_chip_register);
>  void tpm_chip_unregister(struct tpm_chip *chip)
>  {
>  	tpm_del_legacy_sysfs(chip);
> -	if (IS_ENABLED(CONFIG_HW_RANDOM_TPM) && !tpm_is_firmware_upgrade(chip))
> +	if (IS_ENABLED(CONFIG_HW_RANDOM_TPM) && !tpm_is_firmware_upgrade(chip) &&
> +	    !tpm_amd_is_rng_defective(chip))
>  		hwrng_unregister(&chip->hwrng);
>  	tpm_bios_log_teardown(chip);
>  	if (chip->flags & TPM_CHIP_FLAG_TPM2 && !tpm_is_firmware_upgrade(chip))

I'll apply this and apply tested-by from Martin. Thanks for reporting!

BR, Jarkko


      reply	other threads:[~2023-04-24 13:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-23 15:49 [PATCH] tpm: Add !tpm_amd_is_rng_defective() to the hwrng_unregister() call site Jarkko Sakkinen
2023-04-24 13:06 ` 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=2772fde600710b99d482edee903f30bd87ea9aa8.camel@kernel.org \
    --to=jarkko@kernel.org \
    --cc=Jason@zx2c4.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=jgg@ziepe.ca \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@dominikbrodowski.net \
    --cc=mario.limonciello@amd.com \
    --cc=martin@dmarto.com \
    --cc=peterhuewe@gmx.de \
    /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