Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3114853rwb; Mon, 15 Aug 2022 18:28:30 -0700 (PDT) X-Google-Smtp-Source: AA6agR5x5RAQEH8BWd+d832+SLNpuAUrcaVAl+Csl5vYRij8YO40Hl7Pq2W69mszToi1aH56Ewcm X-Received: by 2002:a17:902:db06:b0:16e:e5fc:56d8 with SMTP id m6-20020a170902db0600b0016ee5fc56d8mr19936866plx.100.1660613310141; Mon, 15 Aug 2022 18:28:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660613310; cv=none; d=google.com; s=arc-20160816; b=dI4uTYczKAn82c/qLpZjKywBsYdeH+A3acJGdVsMEXUMUsjix+p9O47aFaIq/twva+ AUs6WlDnucH+J/YTp0yvucDCIQYHlLf08xQl489z6vUlhrmbB5crdjNDbo+HZCoBn7pI o9ipXJdEZz2otSqCd1iyHGwVO42mLKVTLlHUDq4PM2cJm3VcCxt+RCU1E+gQ/xO70u3m QhD6w/EzWKRiWOkeeqJ7pU5XV1I1Rm1OBwhiz/VaUgTZRlXBXEkW1OW5lTS40PP0Z5yn mPVrepAzbVjbyo0OKf8eo4IaIveDIzQfxgl3HgWw+dED3Dt74Bmt1N9sHKUsaVwcGbsm 7PXQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XR1O/ASAF20GNVnty07BA3Jb8BRpoz940R3evxtQHOA=; b=zhNATr10P+fiUeUTG+medjJVurwyxxZh+zMFlGP2uFRXNLFlNJR7/BKHXFbZKtUC1D fQMxXwiYgIQfcr1HaGNxxTEb2Pf6BYlfeuxQd+8qOsAfH0yqBRxaqzeS3J/68I8Devqo 0NV1GvC2/CUagau9CWqWfBp4fZOlVKHBfa0y9GT7QP/nbu/vPJeCCGQF2nHBzjIbGAed uPHZ8qE9SR8dPXWkuUQNt+gmLPkvv7ve4le7n4h51CLpUFuwIlPQFsr8zARIALCu/2qv SM6srf3+I/dKbzgfLGdlLjPSHppjqB+269Gkz+1BWL515r7JOgaqHySXTyRoO75e9sA0 oTKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="AF/4DYqP"; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e11-20020a170902744b00b0016cd74e550fsi11320153plt.351.2022.08.15.18.28.18; Mon, 15 Aug 2022 18:28:30 -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=@linuxfoundation.org header.s=korg header.b="AF/4DYqP"; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349165AbiHPBGI (ORCPT + 99 others); Mon, 15 Aug 2022 21:06:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344044AbiHPBAj (ORCPT ); Mon, 15 Aug 2022 21:00:39 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFCE8DC08B; Mon, 15 Aug 2022 13:50:09 -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 ams.source.kernel.org (Postfix) with ESMTPS id 118E6B8114A; Mon, 15 Aug 2022 20:50:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58B44C433D6; Mon, 15 Aug 2022 20:50:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660596600; bh=NkKMkHknrqEudYOT5PSgk8GZD5Ar1acRpy+li8bhK/Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AF/4DYqPZb/KX0MCpzhrxZZjsxuLqn7as7oRTdbhiFHa6WlQPw25yG2MLbPYGI3nv scDo8RFqVO515xpEyV+wIAxPRgF5W3zewtp48U44Nod4BnNH550Uc4hdONlmvYI0R2 B9Gdpn66UZ44izxiYMhJhJdHEKFQd1uDnGds4PsA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?M=C3=A5rten=20Lindahl?= , Jarkko Sakkinen , Sasha Levin Subject: [PATCH 5.19 1132/1157] tpm: Add check for Failure mode for TPM2 modules Date: Mon, 15 Aug 2022 20:08:08 +0200 Message-Id: <20220815180525.685846400@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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: X-Mailing-List: linux-kernel@vger.kernel.org From: Mårten Lindahl [ Upstream commit 863ed94c589fcd1984f4e3080f069d30508044bb ] In commit 0aa698787aa2 ("tpm: Add Upgrade/Reduced mode support for TPM2 modules") it was said that: "If the TPM is in Failure mode, it will successfully respond to both tpm2_do_selftest() and tpm2_startup() calls. Although, will fail to answer to tpm2_get_cc_attrs_tbl(). Use this fact to conclude that TPM is in Failure mode." But a check was never added in the commit when calling tpm2_get_cc_attrs_tbl() to conclude that the TPM is in Failure mode. This commit corrects this by adding a check. Fixes: 0aa698787aa2 ("tpm: Add Upgrade/Reduced mode support for TPM2 modules") Cc: stable@vger.kernel.org # v5.17+ Signed-off-by: Mårten Lindahl Reviewed-by: Jarkko Sakkinen Signed-off-by: Jarkko Sakkinen Signed-off-by: Sasha Levin --- drivers/char/tpm/tpm2-cmd.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c index c1eb5d223839..65d03867e114 100644 --- a/drivers/char/tpm/tpm2-cmd.c +++ b/drivers/char/tpm/tpm2-cmd.c @@ -752,6 +752,12 @@ int tpm2_auto_startup(struct tpm_chip *chip) } rc = tpm2_get_cc_attrs_tbl(chip); + if (rc == TPM2_RC_FAILURE || (rc < 0 && rc != -ENOMEM)) { + dev_info(&chip->dev, + "TPM in field failure mode, requires firmware upgrade\n"); + chip->flags |= TPM_CHIP_FLAG_FIRMWARE_UPGRADE; + rc = 0; + } out: /* -- 2.35.1