Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3088882rwb; Mon, 15 Aug 2022 17:51:26 -0700 (PDT) X-Google-Smtp-Source: AA6agR6+r5Om2Tg1LvgluT4NKvE278T9MvfujRsRV+TsWS+ELsz9rYPTWt4eRDms1rLXCKiD5FX+ X-Received: by 2002:a17:906:7007:b0:6ff:8028:42e with SMTP id n7-20020a170906700700b006ff8028042emr12104053ejj.278.1660611085850; Mon, 15 Aug 2022 17:51:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611085; cv=none; d=google.com; s=arc-20160816; b=MqWkJjKjK4kVcA7egzPdiL8RhzSrRy6R8MbsEC+4AstmMtMvRQz1IlLg34j98iGUPJ emeOLCGZBbohcNWZv+4Cz3EsfS4uig9QwCV2zwxPCaRsE9k9iEfHgJ3artKGOucGt9zY Jxr9YGIhKd5l8aoWSEG2hpVe+VVpwqWN5wjSsW76pOne9KxlZnbUh/J2kcEUMQYMsaU9 cRHQa+Fo30ogZ1QeB1ajaH93frMNQ3F2dCB01CAbmFfEppJKedrCqiofsIWzZbO+g6bK t/aE3h0MM7rhp+S3QppiwOJxAeskfJfgEnEipzmzoqMavDXi21MmITiwxZnrK1VetN6y EIuA== 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=u1Jl+hzPIpc+HOVYd7yj+CZzymNLmTh8JJJfS5f6cNU=; b=HuVJHc1Tcp0YOm6fxWlJwwG+5M2y1XCcUgZTWydpKBgJdFEzNGNgBS/T3SBrm3ITYk lQ3fzv8hmIzVWPEepI3F/IA4M2E/ESQESJ5oy2zQ6WEULN2jbjJn+Uj1XJInJuu3FgrR wGCv6cxoZUadMOuIuj2cqyh/b6CABfSs32XCdrjw0SiVqrye5BbsRZ9aFSf7nW8mj8ha 9cL8ms5VtZDJ9tNYFr3sC7/qNAy/0oWWJLYBIM+db1DtRUPL1Sq4Kuaq8VW336lH553Z /OId5myZOc1xbMOEwDLm2qMOCucrOmy/C1sDIsJ1oTDPkJMWxNNNnBzQARYeXVUwCQj+ XnHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rBVtPQj9; 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 cy6-20020a0564021c8600b0043d4f544304si8157784edb.342.2022.08.15.17.51.00; Mon, 15 Aug 2022 17:51:25 -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=rBVtPQj9; 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 S1353985AbiHOXkb (ORCPT + 99 others); Mon, 15 Aug 2022 19:40:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346108AbiHOXhT (ORCPT ); Mon, 15 Aug 2022 19:37:19 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52D19152436; Mon, 15 Aug 2022 13:09:48 -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 09739B81135; Mon, 15 Aug 2022 20:09:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53C3FC433C1; Mon, 15 Aug 2022 20:09:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660594185; bh=VcECr1scfMi6H8ackDqfW47OlIEhZMW7KEnHNf/qPdY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rBVtPQj9O6H7UkzU0D15oZE6GayGUI7AfAyHcr9rJzPZ6etXGHnA7orR1xo4U8yei bx8kcah5rqBMFFMuqIMfeeiF5tEMVbjj1JgpIpaaB+udMpF1Wl+gdJdPS/9IF+DRp3 gfmVIwV9PfGthbF4mYRcMYPiSAUs9XaHciENHBac= 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.18 1069/1095] tpm: Add check for Failure mode for TPM2 modules Date: Mon, 15 Aug 2022 20:07:48 +0200 Message-Id: <20220815180513.262690780@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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 04a3e23a4afc..4419593d9531 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: if (rc == TPM2_RC_UPGRADE) { -- 2.35.1