Re: [PATCH v3 2/2] tpm: in tpm2_del_space check if ops pointer is still valid

2021-03-06 Thread Lino Sanfilippo
Hi James, > On 05.02.21 01:34, James Bottomley wrote: >> The reporter went silent before we could get this tested, but could you >> try, please, because your patch is still hand rolling the ops get/put, >> just slightly better than it had been done previously. > > I tested your patch and it fixes

Re: [PATCH v3 2/2] tpm: in tpm2_del_space check if ops pointer is still valid

2021-02-14 Thread Lino Sanfilippo
Hi, On 12.02.21 at 11:59, Jarkko Sakkinen wrote: > > One *option*: > > 1. You take the Jason's patch. > 2. > https://www.kernel.org/doc/html/v5.10/process/submitting-patches.html#when-to-use-acked-by-cc-and-co-developed-by > > Just mentioning this, and spreading the knowledge about co-developed-

Re: [PATCH v3 2/2] tpm: in tpm2_del_space check if ops pointer is still valid

2021-02-12 Thread Jarkko Sakkinen
On Tue, Feb 09, 2021 at 09:36:53AM -0400, Jason Gunthorpe wrote: > On Tue, Feb 09, 2021 at 12:52:17PM +0100, Lino Sanfilippo wrote: > > > @@ -640,8 +643,10 @@ void tpm_chip_unregister(struct tpm_chip *chip) > > > if (IS_ENABLED(CONFIG_HW_RANDOM_TPM)) > > > hwrng_unregister(&chip->hwrng)

Re: [PATCH v3 2/2] tpm: in tpm2_del_space check if ops pointer is still valid

2021-02-12 Thread Jarkko Sakkinen
On Tue, Feb 09, 2021 at 12:52:17PM +0100, Lino Sanfilippo wrote: > Hi Jason, > > On 05.02.21 18:25, Jason Gunthorpe wrote: > > On Fri, Feb 05, 2021 at 08:48:11AM -0800, James Bottomley wrote: > >>> Thanks for pointing this out. I'd strongly support Jason's proposal: > >>> > >>> https://lore.kernel

Re: [PATCH v3 2/2] tpm: in tpm2_del_space check if ops pointer is still valid

2021-02-09 Thread Lino Sanfilippo
On 09.02.21 14:36, Jason Gunthorpe wrote: >>> EXPORT_SYMBOL_GPL(tpm_chip_unregister); >>> >> >> I tested the solution you scetched and it fixes the issue for me. Will you >> send a (real) patch for this? > > No, feel free to bundle this up with any fixes needed and send it with > a Signed-of

Re: [PATCH v3 2/2] tpm: in tpm2_del_space check if ops pointer is still valid

2021-02-09 Thread Jason Gunthorpe
On Tue, Feb 09, 2021 at 12:52:17PM +0100, Lino Sanfilippo wrote: > > @@ -640,8 +643,10 @@ void tpm_chip_unregister(struct tpm_chip *chip) > > if (IS_ENABLED(CONFIG_HW_RANDOM_TPM)) > > hwrng_unregister(&chip->hwrng); > > tpm_bios_log_teardown(chip); > > - if (chip->flags & TPM_

Re: [PATCH v3 2/2] tpm: in tpm2_del_space check if ops pointer is still valid

2021-02-09 Thread Lino Sanfilippo
Hi Jason, On 05.02.21 18:25, Jason Gunthorpe wrote: > On Fri, Feb 05, 2021 at 08:48:11AM -0800, James Bottomley wrote: >>> Thanks for pointing this out. I'd strongly support Jason's proposal: >>> >>> https://lore.kernel.org/linux-integrity/20201215175624.gg5...@ziepe.ca/ >>> >>> It's the best long

Re: [PATCH v3 2/2] tpm: in tpm2_del_space check if ops pointer is still valid

2021-02-05 Thread Jason Gunthorpe
On Fri, Feb 05, 2021 at 09:54:29AM -0800, James Bottomley wrote: > On Fri, 2021-02-05 at 13:25 -0400, Jason Gunthorpe wrote: > > On Fri, Feb 05, 2021 at 08:48:11AM -0800, James Bottomley wrote: > > > > Thanks for pointing this out. I'd strongly support Jason's > > > > proposal: > > > > > > > > htt

Re: [PATCH v3 2/2] tpm: in tpm2_del_space check if ops pointer is still valid

2021-02-05 Thread Jason Gunthorpe
On Fri, Feb 05, 2021 at 05:08:20PM -0800, James Bottomley wrote: > Effectively all of this shuffles the tpmrm device allocation from > chip_alloc to chip_add ... I'm not averse to this but it does mean we > can suffer allocation failures now in the add routine and it makes > error handling a bit

Re: [PATCH v3 2/2] tpm: in tpm2_del_space check if ops pointer is still valid

2021-02-05 Thread James Bottomley
On Fri, 2021-02-05 at 13:25 -0400, Jason Gunthorpe wrote: > On Fri, Feb 05, 2021 at 08:48:11AM -0800, James Bottomley wrote: [...] > > The practical consequence of this model is that if you allocate a > > chip structure with tpm_chip_alloc() you have to release it again > > by doing a put of *both*

Re: [PATCH v3 2/2] tpm: in tpm2_del_space check if ops pointer is still valid

2021-02-05 Thread James Bottomley
On Fri, 2021-02-05 at 04:18 +0200, Jarkko Sakkinen wrote: > On Thu, Feb 04, 2021 at 04:34:11PM -0800, James Bottomley wrote: > > On Fri, 2021-02-05 at 00:50 +0100, Lino Sanfilippo wrote: > > > From: Lino Sanfilippo > > > > > > In tpm2_del_space() chip->ops is used for flushing the sessions. > > >

Re: [PATCH v3 2/2] tpm: in tpm2_del_space check if ops pointer is still valid

2021-02-05 Thread James Bottomley
On Fri, 2021-02-05 at 13:25 -0400, Jason Gunthorpe wrote: > On Fri, Feb 05, 2021 at 08:48:11AM -0800, James Bottomley wrote: > > > Thanks for pointing this out. I'd strongly support Jason's > > > proposal: > > > > > > https://lore.kernel.org/linux-integrity/20201215175624.gg5...@ziepe.ca/ > > > >

Re: [PATCH v3 2/2] tpm: in tpm2_del_space check if ops pointer is still valid

2021-02-05 Thread Jason Gunthorpe
On Fri, Feb 05, 2021 at 08:48:11AM -0800, James Bottomley wrote: > > Thanks for pointing this out. I'd strongly support Jason's proposal: > > > > https://lore.kernel.org/linux-integrity/20201215175624.gg5...@ziepe.ca/ > > > > It's the best long-term way to fix this. > > Really, no it's not. It

Re: [PATCH v3 2/2] tpm: in tpm2_del_space check if ops pointer is still valid

2021-02-05 Thread Lino Sanfilippo
Hi James, On 05.02.21 01:34, James Bottomley wrote: > > > Actually, this still isn't right. As I said to the last person who > reported this, we should be doing a get/put on the ops, not rolling our > own here: > > https://lore.kernel.org/linux-integrity/e7566e1e48f5be9dca034b4bfb67683b5d3cb

Re: [PATCH v3 2/2] tpm: in tpm2_del_space check if ops pointer is still valid

2021-02-04 Thread Greg KH
On Fri, Feb 05, 2021 at 12:50:43AM +0100, Lino Sanfilippo wrote: > From: Lino Sanfilippo > > In tpm2_del_space() chip->ops is used for flushing the sessions. However > this function may be called after tpm_chip_unregister() which sets > the chip->ops pointer to NULL. > Avoid a possible NULL point

Re: [PATCH v3 2/2] tpm: in tpm2_del_space check if ops pointer is still valid

2021-02-04 Thread Jarkko Sakkinen
On Thu, Feb 04, 2021 at 04:34:11PM -0800, James Bottomley wrote: > On Fri, 2021-02-05 at 00:50 +0100, Lino Sanfilippo wrote: > > From: Lino Sanfilippo > > > > In tpm2_del_space() chip->ops is used for flushing the sessions. > > However > > this function may be called after tpm_chip_unregister() w

Re: [PATCH v3 2/2] tpm: in tpm2_del_space check if ops pointer is still valid

2021-02-04 Thread James Bottomley
On Fri, 2021-02-05 at 00:50 +0100, Lino Sanfilippo wrote: > From: Lino Sanfilippo > > In tpm2_del_space() chip->ops is used for flushing the sessions. > However > this function may be called after tpm_chip_unregister() which sets > the chip->ops pointer to NULL. > Avoid a possible NULL pointer de

[PATCH v3 2/2] tpm: in tpm2_del_space check if ops pointer is still valid

2021-02-04 Thread Lino Sanfilippo
From: Lino Sanfilippo In tpm2_del_space() chip->ops is used for flushing the sessions. However this function may be called after tpm_chip_unregister() which sets the chip->ops pointer to NULL. Avoid a possible NULL pointer dereference by checking if chip->ops is still valid before accessing it.