Message ID | 20230423154958.805992-1-jarkko@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2258205vqo; Sun, 23 Apr 2023 08:51:14 -0700 (PDT) X-Google-Smtp-Source: AKy350ZgaGRnv9X2+BtZ0lPyZNdmicgKiJJrdgjbGKE1AqsG2YpG1d789zgSLL9LOnGIgR9kJapf X-Received: by 2002:a17:90a:ee86:b0:247:90ea:1a81 with SMTP id i6-20020a17090aee8600b0024790ea1a81mr11881949pjz.37.1682265074601; Sun, 23 Apr 2023 08:51:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682265074; cv=none; d=google.com; s=arc-20160816; b=kNd7cH3QXsekMsOgCfNChj7gTcGVRS4S8m1PgUwU16Vy21u6rSLNPXjsQSWA1sAGva SBaCJ9+Dk1a7h0FtT2u1HFG0d7H/Q7ZKIIgKg3lC/0dWsOBir8QJT4a24Yo8rb7A2nOB jHPTr/BIL7XVpE6nvRAfBCguEqBA3osR9vCrJozHO1Zbfr6Y4pT/81eETRn8rXKjGD3T e6B+2tATDXSW2nowdzBEfbaYjDebtLYYz8zPF7Jne09vIgwhrLXHKaCOGuch8ggXwdDN HCZQvx3NH6LmkMEksrfqVrzehKPqmJV2Zxg6iLFsRCcdlc+Zn+3j5GgAq+vpWeyEimpJ yrhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=P/gqssjDEQiCaHvOko0ryMHDdtx7Lvn0E8F2QtxPoTg=; b=PHe/ulnLW/7NbaCqKek3Ve7LRvwFVgxdTG/z4BfX95m8/uUUDjTQj9dmsaxP71KC6c hZpaPV+3ixenmgz/wcKykSF+o/+3OGGKlTbWN5dqS4MOV4GA5Y3/QDXXG3DR8wHe8fqg iaxHAkLkX4uOCrz/ylsJy3fp08+D7vIogvmYF88h6YkV2sQAIMQJi7T0zThkvjwfMsn6 dATZ7hT3vCKTk6E/l9/vz3QuvERUhwdbKLFc6xtdbCvNAS/nRcjIFan0UkbNDMrAb/EM O4FzLeW3Hk2twYuA9aNEOonUlIHtTinPh1APOh0i/vijEZATPW8Rhz+81kA8eRe8Yxf0 VdOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nsiZ4pMa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ie10-20020a17090b400a00b002449259314esi7109225pjb.158.2023.04.23.08.51.02; Sun, 23 Apr 2023 08:51:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nsiZ4pMa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229611AbjDWPuG (ORCPT <rfc822;fengqi706@gmail.com> + 99 others); Sun, 23 Apr 2023 11:50:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229615AbjDWPuE (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 23 Apr 2023 11:50:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A5A2E51; Sun, 23 Apr 2023 08:50:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B1410614A5; Sun, 23 Apr 2023 15:50:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 929A7C433D2; Sun, 23 Apr 2023 15:50:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682265002; bh=uz157tjFSjPvS0caMpsIus4wA/SfBsI/pU6q3ps1DYY=; h=From:To:Cc:Subject:Date:From; b=nsiZ4pManAKyLfWpMgQrfBArhmiARbLo4l2k042eCn0eEQr6fPeqcjcCntuppCywO HqEzKw3eSzcS7JZmQNZCiHBhH0U9EkRruORul0rf88ABBcdX1RMNsj2+LQkhSkH84t dR8JqHPBzuE4Ov/O2PGRI9URxUEP2ZnDeMZnJ+Xoor+ccjzObONNg5PvNKNoHcU9C3 aVJ4BGB/j3nnKH6IxJkuf+WV83ZPGaR6ObOdVzSYIL1cHoiRHpYRD0beVxOX21aCyM 3qTf4DqHBWhL4RjGaiimFpq/Z3hfzNdDE0fJFCOvHZCy9NcxjVW0eRv1KmL967IiTJ eJSVR2RVsz04g== From: Jarkko Sakkinen <jarkko@kernel.org> To: Peter Huewe <peterhuewe@gmx.de>, Jarkko Sakkinen <jarkko@kernel.org>, 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: [PATCH] tpm: Add !tpm_amd_is_rng_defective() to the hwrng_unregister() call site Date: Sun, 23 Apr 2023 18:49:58 +0300 Message-Id: <20230423154958.805992-1-jarkko@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763982782892442423?= X-GMAIL-MSGID: =?utf-8?q?1763982782892442423?= |
Series |
tpm: Add !tpm_amd_is_rng_defective() to the hwrng_unregister() call site
|
|
Commit Message
Jarkko Sakkinen
April 23, 2023, 3:49 p.m. UTC
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(-)
Comments
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
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))