From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 997B9C4360C for ; Tue, 8 Oct 2019 09:41:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 75273206BB for ; Tue, 8 Oct 2019 09:41:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729928AbfJHJlZ (ORCPT ); Tue, 8 Oct 2019 05:41:25 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:35673 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729790AbfJHJlY (ORCPT ); Tue, 8 Oct 2019 05:41:24 -0400 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id 2EE0C803E2; Tue, 8 Oct 2019 11:41:07 +0200 (CEST) Date: Tue, 8 Oct 2019 11:41:21 +0200 From: Pavel Machek To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Vadim Sukhomlinov , Douglas Anderson , Jarkko Sakkinen , Sasha Levin Subject: Re: [PATCH 4.19 002/106] tpm: Fix TPM 1.2 Shutdown sequence to prevent future TPM operations Message-ID: <20191008094121.GA608@amd> References: <20191006171124.641144086@linuxfoundation.org> <20191006171126.123065744@linuxfoundation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="0F1p//8PRICkK4MW" Content-Disposition: inline In-Reply-To: <20191006171126.123065744@linuxfoundation.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org --0F1p//8PRICkK4MW Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > From: Vadim Sukhomlinov >=20 > commit db4d8cb9c9f2af71c4d087817160d866ed572cc9 upstream >=20 > 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. =2E.. > --- 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 =3D container_of(dev, struct tpm_chip, dev); > =20 > + 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 =3D NULL; > - up_write(&chip->ops_sem); > } > + chip->ops =3D NULL; > + up_write(&chip->ops_sem); > =20 > return 0; > } Still can be improved -- chip->ops =3D NULL; is done twice, copy inside the if {} is redundant... Best regards, Pavel --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --0F1p//8PRICkK4MW Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAl2cWcEACgkQMOfwapXb+vLbYgCffR+Ik90cUuBHAYxxqbhhX8S4 ir0An1MyxGfX0btyAtBfH9oInfWUUBFA =XvM4 -----END PGP SIGNATURE----- --0F1p//8PRICkK4MW--