Message ID | 20230215092552.3004363-1-morten@linderud.pw |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp97139wrn; Wed, 15 Feb 2023 01:47:22 -0800 (PST) X-Google-Smtp-Source: AK7set+FhI6Ap/VsUqvzsQUHCIBFTwVQtgLzvO5almfGoB4kOxwtpcnWfADMdytwRYk0VKkpwwXd X-Received: by 2002:a05:6a20:a299:b0:c2:b228:e36 with SMTP id a25-20020a056a20a29900b000c2b2280e36mr1098383pzl.13.1676454442689; Wed, 15 Feb 2023 01:47:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676454442; cv=none; d=google.com; s=arc-20160816; b=YMoseYtRMjRAscFz7LF9iOWrLiLlDy+/WsvGiJew/30QLCIiTyHu8IKSP4J04aF1yY +DykjrjjwatkEuUHfAWk1Va27ZwfPGzGwuFtybJmTZrfv8gx1mFX8wt70o8Wm5YYfLsn GLnOHxdoZkHBVfghhyVVeLApyPBeRloOcqsuHnUp5xyV1b00zasSjXcVVyjEs9S3mXTY sIxQPr5yUe0b2nIsnwquSMrTeZRAhH5MxAzFvL1iMC4KV6DFrV/brrVo8lGMl6AlOq9a 2NCVUR/SmBwo9+xc5W25RxHrBS+Sb1058x8GAVsClmWeEYHCabH0k3JXsfxuIYtaeOaS 75/g== 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=sAeF8ELHJGKQn0wnhFLl19SDsR5x8Q5S9wjosmmSQyo=; b=k5r/gyM2Tq4PKUO729F5VyJv76c6Kd7ByI8xQLWCzEvCFi5WuhuilOs9EP+YLlHdPB COOavdhWzXavuixNw8n1dUjgxckW18n5HoOFizW7ASUunvVwrDpf68UqhpTVx6uK3nk7 UY1e5fAIKfx6UpWSmVudi/JFsdM5m63gWX/1Kid/C8qy+wRGZffUTbj8kOI++1Vrc9Cs JRs/EI2UvJ0pk4ax/ekyAz4VDGvslMXwtScHWiNcQ3QwU6sQ0+A60KvLQVtSBl2MIjUH rEaAA3nY6Oc0vVOqb+1qTARtmkz4y9/sE+jFGPJvcOi8vVJU51PZLX5XOcDEuw30kEPM 8rgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linderud.pw header.s=linderud header.b=QqN6IbVu; 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=linderud.pw Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w129-20020a623087000000b00593115af5a6si15296475pfw.260.2023.02.15.01.47.10; Wed, 15 Feb 2023 01:47:22 -0800 (PST) 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=@linderud.pw header.s=linderud header.b=QqN6IbVu; 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=linderud.pw Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233894AbjBOJn5 (ORCPT <rfc822;tebrre53rla2o@gmail.com> + 99 others); Wed, 15 Feb 2023 04:43:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234099AbjBOJnm (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 15 Feb 2023 04:43:42 -0500 X-Greylist: delayed 601 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 15 Feb 2023 01:43:39 PST Received: from linderud.pw (linderud.dev [163.172.10.146]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 746FCB442; Wed, 15 Feb 2023 01:43:37 -0800 (PST) Received: from linderud.pw (localhost [127.0.0.1]) by linderud.pw (Postfix) with ESMTP id E641BC02F6; Wed, 15 Feb 2023 10:27:37 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linderud.pw; s=linderud; t=1676453257; bh=JcWAyn8q70xL4QFfQr72WF4KdrylqsGgjLNgZGECBXc=; h=From:To:Cc:Subject:Date; b=QqN6IbVuNl4SKsNs6n4H8RbcxzxkfupowKT9WfPrNyAtjKROJApNgXequyk1Si5wG Bad48OGwDd94bD8bIHL57A6qi3eUQ6sSObzwKBg7E8duo15DyL22UyAxebudRd4v0W yqtcipBlP5ckeQBEfaK9rZA1t+8kvF0qL8qDomh64duFXCh/bm6H7R1kqtWlB1H3px G8B0iPDcS8M9vT2BRvVvJUgai/D8I5tj9mIqbrMYAP8WOiHnRQskRuVNITUL3gNn9O SV5Pfr+uIArA+mmyyZigxb72eyT/sFNYdEUf7ErILfrnqAr4kzaNZi6zEguyHkWHur DAGLNrD4yHMwVgWvZxQn7NhHj0ZpjSo1et+jphEpwtya3fJl9AeooG2bFLmwImUGIS TLaUbKi5hZXTwGkm5iS6ITam11vhhZ4lnWNZ7m3040u1ovfOjcALAV2NNyDoHLnsHs sa+V6hX3fLQsLeoRG/AmQyCaooCc3o+tdPhYQzlodt3/lCc8UO4JseCDctBT+U12v4 4Ag7nnLYWEhCNtR4bm1o8K2pVlWl8taYZgixKSBfRlf62VEzyRwLPxZLz51T/k8CQU Gxhi/STUDwuaA0cF4IYDcGEfjvdSF09Ovfsp+Ea6dHLspmuC6UddusAr6ogbSsrx7b 7fsHPx4Vefkl4HCaCBDNZblo= Received: from localhost (eth1-9-167-demarc.sto-kn6.obe.net [195.128.255.107]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: morten) by linderud.pw (Postfix) with ESMTPSA id A6460C015E; Wed, 15 Feb 2023 10:27:37 +0100 (CET) From: Morten Linderud <morten@linderud.pw> To: linux-kernel@vger.kernel.org, linux-integrity@vger.kernel.org, jgg@ziepe.ca, jarkko@kernel.org, peterhuewe@gmx.de Cc: Morten Linderud <morten@linderud.pw>, Erkki Eilonen <erkki@bearmetal.eu> Subject: [PATCH v3] tpm/eventlog: Don't abort tpm_read_log on faulty ACPI address Date: Wed, 15 Feb 2023 10:25:52 +0100 Message-Id: <20230215092552.3004363-1-morten@linderud.pw> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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?1757889893670335493?= X-GMAIL-MSGID: =?utf-8?q?1757889893670335493?= |
Series |
[v3] tpm/eventlog: Don't abort tpm_read_log on faulty ACPI address
|
|
Commit Message
Morten Linderud
Feb. 15, 2023, 9:25 a.m. UTC
tpm_read_log_acpi() should return -ENODEV when no eventlog from the ACPI table is found. If the firmware vendor includes an invalid log address we are unable to map from the ACPI memory and tpm_read_log() returns -EIO which would abort discovery of the eventlog. Change the return value from -EIO to -ENODEV when acpi_os_map_iomem() fails to map the event log. The following hardware was used to test this issue: Framework Laptop (Pre-production) BIOS: INSYDE Corp, Revision: 3.2 TPM Device: NTC, Firmware Revision: 7.2 Dump of the faulty ACPI TPM2 table: [000h 0000 4] Signature : "TPM2" [Trusted Platform Module hardware interface Table] [004h 0004 4] Table Length : 0000004C [008h 0008 1] Revision : 04 [009h 0009 1] Checksum : 2B [00Ah 0010 6] Oem ID : "INSYDE" [010h 0016 8] Oem Table ID : "TGL-ULT" [018h 0024 4] Oem Revision : 00000002 [01Ch 0028 4] Asl Compiler ID : "ACPI" [020h 0032 4] Asl Compiler Revision : 00040000 [024h 0036 2] Platform Class : 0000 [026h 0038 2] Reserved : 0000 [028h 0040 8] Control Address : 0000000000000000 [030h 0048 4] Start Method : 06 [Memory Mapped I/O] [034h 0052 12] Method Parameters : 00 00 00 00 00 00 00 00 00 00 00 00 [040h 0064 4] Minimum Log Length : 00010000 [044h 0068 8] Log Address : 000000004053D000 Fixes: 0cf577a03f21 ("tpm: Fix handling of missing event log") Tested-By: Erkki Eilonen <erkki@bearmetal.eu> Signed-off-by: Morten Linderud <morten@linderud.pw> --- v2: Tweak commit message and opt to return -ENODEV instead of loosening up the if condition in tpm_read_log() v3: Mention function name instead of "this" in the commit log. Added Tested-By and Fixes tags --- drivers/char/tpm/eventlog/acpi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Comments
On Wed, Feb 15, 2023 at 10:25:52AM +0100, Morten Linderud wrote: > tpm_read_log_acpi() should return -ENODEV when no eventlog from the ACPI > table is found. If the firmware vendor includes an invalid log address > we are unable to map from the ACPI memory and tpm_read_log() returns -EIO > which would abort discovery of the eventlog. > > Change the return value from -EIO to -ENODEV when acpi_os_map_iomem() > fails to map the event log. > > The following hardware was used to test this issue: > Framework Laptop (Pre-production) > BIOS: INSYDE Corp, Revision: 3.2 > TPM Device: NTC, Firmware Revision: 7.2 > > Dump of the faulty ACPI TPM2 table: > [000h 0000 4] Signature : "TPM2" [Trusted Platform Module hardware interface Table] > [004h 0004 4] Table Length : 0000004C > [008h 0008 1] Revision : 04 > [009h 0009 1] Checksum : 2B > [00Ah 0010 6] Oem ID : "INSYDE" > [010h 0016 8] Oem Table ID : "TGL-ULT" > [018h 0024 4] Oem Revision : 00000002 > [01Ch 0028 4] Asl Compiler ID : "ACPI" > [020h 0032 4] Asl Compiler Revision : 00040000 > > [024h 0036 2] Platform Class : 0000 > [026h 0038 2] Reserved : 0000 > [028h 0040 8] Control Address : 0000000000000000 > [030h 0048 4] Start Method : 06 [Memory Mapped I/O] > > [034h 0052 12] Method Parameters : 00 00 00 00 00 00 00 00 00 00 00 00 > [040h 0064 4] Minimum Log Length : 00010000 > [044h 0068 8] Log Address : 000000004053D000 > > Fixes: 0cf577a03f21 ("tpm: Fix handling of missing event log") > Tested-By: Erkki Eilonen <erkki@bearmetal.eu> > Signed-off-by: Morten Linderud <morten@linderud.pw> > > --- > > v2: Tweak commit message and opt to return -ENODEV instead of loosening up the > if condition in tpm_read_log() > > v3: Mention function name instead of "this" in the commit log. Added Tested-By > and Fixes tags > > --- > drivers/char/tpm/eventlog/acpi.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/char/tpm/eventlog/acpi.c b/drivers/char/tpm/eventlog/acpi.c > index 0913d3eb8d51..cd266021d010 100644 > --- a/drivers/char/tpm/eventlog/acpi.c > +++ b/drivers/char/tpm/eventlog/acpi.c > @@ -143,8 +143,12 @@ int tpm_read_log_acpi(struct tpm_chip *chip) > > ret = -EIO; > virt = acpi_os_map_iomem(start, len); > - if (!virt) > + if (!virt) { > + dev_warn(&chip->dev, "%s: Failed to map ACPI memory\n", __func__); > + /* try EFI log next */ > + ret = -ENODEV; > goto err; > + } > > memcpy_fromio(log->bios_event_log, virt, len); > > -- > 2.39.1 Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org> I'll apply this soon, thanks. BR, Jarkko
diff --git a/drivers/char/tpm/eventlog/acpi.c b/drivers/char/tpm/eventlog/acpi.c index 0913d3eb8d51..cd266021d010 100644 --- a/drivers/char/tpm/eventlog/acpi.c +++ b/drivers/char/tpm/eventlog/acpi.c @@ -143,8 +143,12 @@ int tpm_read_log_acpi(struct tpm_chip *chip) ret = -EIO; virt = acpi_os_map_iomem(start, len); - if (!virt) + if (!virt) { + dev_warn(&chip->dev, "%s: Failed to map ACPI memory\n", __func__); + /* try EFI log next */ + ret = -ENODEV; goto err; + } memcpy_fromio(log->bios_event_log, virt, len);