From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755988AbcH1SwK (ORCPT ); Sun, 28 Aug 2016 14:52:10 -0400 Received: from quartz.orcorp.ca ([184.70.90.242]:46453 "EHLO quartz.orcorp.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755872AbcH1SwI (ORCPT ); Sun, 28 Aug 2016 14:52:08 -0400 Date: Sun, 28 Aug 2016 12:51:49 -0600 From: Jason Gunthorpe To: Jarkko Sakkinen Cc: Peter Huewe , linux-security-module@vger.kernel.org, stable@vger.kernel.org, Marcel Selhorst , "moderated list:TPM DEVICE DRIVER" , open list Subject: Re: [PATCH] tpm: fix a race condition in tpm2_unseal_trusted() Message-ID: <20160828185149.GF12783@obsidianresearch.com> References: <1472366212-8571-1-git-send-email-jarkko.sakkinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1472366212-8571-1-git-send-email-jarkko.sakkinen@linux.intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Aug 28, 2016 at 08:36:52AM +0200, Jarkko Sakkinen wrote: > > @@ -576,7 +576,8 @@ static int tpm2_load(struct tpm_chip *chip, > goto out; > } > > - rc = tpm_transmit_cmd(chip, buf.data, PAGE_SIZE, "loading blob"); > + rc = tpm_transmit_cmd(chip, buf.data, PAGE_SIZE, TPM_TRANSMIT_UNLOCKED, > + "loading blob"); I still don't like this, required mutex's should not be split outside the function that needs them without more a more obvious indication: > + mutex_lock(&chip->tpm_mutex); > rc = tpm2_load(chip, payload, options, &blob_handle); > if (rc) > - return rc; I recommend you stick with the idiom and do this: mutex_lock(&chip->tpm_mutex); rc = tpm2_load(chip, payload, options, &blob_handle, TPM_TRANSMIT_UNLOCKED); Which makes it easy to see we are doing it right everywhere. Jason