Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp2217517ybe; Tue, 3 Sep 2019 09:32:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqyYJNfTXU8So6jeHAL5HHknEJCOJxC2pDBfsz9MkF6EC919pQTDCbX+qLcjyzaTX2RFaong X-Received: by 2002:a62:26c4:: with SMTP id m187mr42648828pfm.49.1567528333567; Tue, 03 Sep 2019 09:32:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567528333; cv=none; d=google.com; s=arc-20160816; b=NjiO+Hhjo/UinksUp86UAGfNPF4CQYTdSd2Y91DJ4fdR6UdPMzYD70nNkWQfhCzVEG RNOnu3zHP9xH3QiFp8S8dEcrsSNlZG3HxU22vRnIKgBfJ2ms5CosY57LFl3CFONY0MQ1 H9z7sFTnfkoOC5G9X1KavkK87nDPcW3FjL/wWY5G/ZGDJh/+dkxgM6I8+2k9bqQv0LoK xkhuCpnOmt/aNJAGPQ1rSm0xO7XUrqSjO2Rgyh0ncvGOUPvC5F2v+/QvIbI7CLdcOTn4 74M3/UYj2UKOhf47YkUmZqnwixLp9VyXkc5WIS3y4RetDljs4/MwQwmToEchDJq53kEt agvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7rCy4f5iKmihfY0V/yi04/jRCb/IDl9lgbDjIMnsQaQ=; b=bntVsx3u321uBqCwSaXIZ5hKSWsxayWfgqpsCsCNwVH0F7f0gZ1Az3x40cXblPxWDK nnNI5MCYE3CtCOTS+5Gtf64ZuLJydIk2/3Z0GXDz883f2dS61Jz0lw6snId5hLNfYBDd qHQE2IF2rGF1BJ4mupKg7GVy96egfW4E87EZb0x2Nb5c8WxeLuPjccBAUgKUFm2cnVLU 1M0bxqAh5VyjGObQrGvQwx16nnsqkcEIAc9l2zVrxBIchi1/advDOh7XJ1IEZoLlt1Th GxcVTvL4yNvG9VVro+oLhSyw2MMXafSqSiknT9/HFPWed22rPGopcp3Y0DNHfsVJVp4t AZ5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yO0+zYbu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l1si15900994pgs.458.2019.09.03.09.31.57; Tue, 03 Sep 2019 09:32:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yO0+zYbu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1731049AbfICQaj (ORCPT + 99 others); Tue, 3 Sep 2019 12:30:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:51236 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731186AbfICQ2v (ORCPT ); Tue, 3 Sep 2019 12:28:51 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 75FEB23789; Tue, 3 Sep 2019 16:28:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567528131; bh=q4Y2kzB82rNvxd7A/88puPWBLD394Qg63gorAKZR084=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yO0+zYbuv2h4CO87zleZ8yOGSIFR5f69v9ATYY37yBFE9pnKKfao4P3YUMrKMuvlo Nnuk2xlbCSwMt4GdswPfC9tZqNFvwp6whhYpnO+OQoAA1Qj8Zy1//iINFH08KFBT+h ojp03Qigxr1hH5YY4vO2EVb04FG7eZV1Ira2qDes= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Vadim Sukhomlinov , Douglas Anderson , Jarkko Sakkinen , Sasha Levin , linux-integrity@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 126/167] tpm: Fix TPM 1.2 Shutdown sequence to prevent future TPM operations Date: Tue, 3 Sep 2019 12:24:38 -0400 Message-Id: <20190903162519.7136-126-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190903162519.7136-1-sashal@kernel.org> References: <20190903162519.7136-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vadim Sukhomlinov [ Upstream commit db4d8cb9c9f2af71c4d087817160d866ed572cc9 ] TPM 2.0 Shutdown involve sending TPM2_Shutdown to TPM chip and disabling future TPM operations. TPM 1.2 behavior was different, future TPM operations weren't disabled, causing rare issues. This patch ensures that future TPM operations are disabled. Fixes: d1bd4a792d39 ("tpm: Issue a TPM2_Shutdown for TPM2 devices.") Cc: stable@vger.kernel.org Signed-off-by: Vadim Sukhomlinov [dianders: resolved merge conflicts with mainline] Signed-off-by: Douglas Anderson Reviewed-by: Jarkko Sakkinen Signed-off-by: Jarkko Sakkinen Signed-off-by: Sasha Levin --- drivers/char/tpm/tpm-chip.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c index 46caadca916a0..0b01eb7b14e53 100644 --- a/drivers/char/tpm/tpm-chip.c +++ b/drivers/char/tpm/tpm-chip.c @@ -187,12 +187,13 @@ static int tpm_class_shutdown(struct device *dev) { struct tpm_chip *chip = container_of(dev, struct tpm_chip, dev); + down_write(&chip->ops_sem); if (chip->flags & TPM_CHIP_FLAG_TPM2) { - down_write(&chip->ops_sem); tpm2_shutdown(chip, TPM2_SU_CLEAR); chip->ops = NULL; - up_write(&chip->ops_sem); } + chip->ops = NULL; + up_write(&chip->ops_sem); return 0; } -- 2.20.1