lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160829152520.GA9063@intel.com>
Date:   Mon, 29 Aug 2016 18:25:21 +0300
From:   Jarkko Sakkinen <jarkko.sakkinen@...ux.intel.com>
To:     Jason Gunthorpe <jgunthorpe@...idianresearch.com>
Cc:     Peter Huewe <peterhuewe@....de>,
        linux-security-module@...r.kernel.org, stable@...r.kernel.org,
        Marcel Selhorst <tpmdd@...horst.net>,
        "moderated list:TPM DEVICE DRIVER" 
        <tpmdd-devel@...ts.sourceforge.net>,
        open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] tpm: fix a race condition in tpm2_unseal_trusted()

On Sun, Aug 28, 2016 at 12:51:49PM -0600, Jason Gunthorpe wrote:
> 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.

Why consume stack for unnecessary stuff? This is a static function. For
me this sounds like cutting hairs really.

One thing that would improve readability would be to rename internal
functions tpm2_load and tpm2_unseal to tpm2_load_cmd and tpm2_unseal_cmd
in order to underline that they are command wrappers and not to mix with
tpm2_unseal_trusted().

I've been thinking to move that kind of convetion at least with TPM2
specific stuff when a function is clearly a wrapper. It kind of
documents the call path. I.e. if function satifies a constraint that
it prepares a command blob, calls tpm_transmit_cmd once and then
returns results to the caller this would be the naming convention.

> Jason

/Jarkko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ