Re: [PATCH v3 1/2] tpm: fix reference counting for struct tpm_chip

2021-02-05 Thread Jason Gunthorpe
On Fri, Feb 05, 2021 at 10:50:02PM +0100, Lino Sanfilippo wrote: > On 05.02.21 at 16:58, Jason Gunthorpe wrote: > eference in the first place). > > > > No, they are all chained together because they are all in the same > > struct: > > > > struct tpm_chip { > > struct device dev; > > struct

Re: [PATCH v3 1/2] tpm: fix reference counting for struct tpm_chip

2021-02-05 Thread Jason Gunthorpe
On Fri, Feb 05, 2021 at 12:50:42AM +0100, Lino Sanfilippo wrote: > From: Lino Sanfilippo > > The following sequence of operations results in a refcount warning: > > 1. Open device /dev/tpmrm > 2. Remove module tpm_tis_spi > 3. Write a TPM command to the file descriptor opened at step 1. > >

Re: [PATCH v3 1/2] tpm: fix reference counting for struct tpm_chip

2021-02-05 Thread Stefan Berger
On 2/4/21 9:01 PM, James Bottomley wrote: On Thu, 2021-02-04 at 20:44 -0500, Stefan Berger wrote: To clarify: When I tested this I had *both* patches applied. Without the patches I got the null pointer exception in tpm2_del_space(). The 2nd patch alone solves that issue when using the steps

Re: [PATCH v3 1/2] tpm: fix reference counting for struct tpm_chip

2021-02-05 Thread Jason Gunthorpe
On Fri, Feb 05, 2021 at 04:50:13PM +0100, Lino Sanfilippo wrote: > > On 05.02.21 16:15, Jason Gunthorpe wrote: > > > > No, the cdev layer holds the refcount on the device while open is > > being called. > > > Yes, but the reference that is responsible for the chip deallocation is > chip->dev >

Re: [PATCH v3 1/2] tpm: fix reference counting for struct tpm_chip

2021-02-05 Thread Lino Sanfilippo
Hi, On 05.02.21 14:05, Jason Gunthorpe wrote: >> >> Commit fdc915f7f719 ("tpm: expose spaces via a device link /dev/tpmrm") >> already introduced function tpm_devs_release() to release the extra >> reference but did not implement the required put on chip->devs that results >> in the call of this

Re: [PATCH v3 1/2] tpm: fix reference counting for struct tpm_chip

2021-02-05 Thread Jason Gunthorpe
On Fri, Feb 05, 2021 at 03:55:09PM +0100, Lino Sanfilippo wrote: > Hi, > > On 05.02.21 14:05, Jason Gunthorpe wrote: > > >> > >> Commit fdc915f7f719 ("tpm: expose spaces via a device link /dev/tpmrm") > >> already introduced function tpm_devs_release() to release the extra > >> reference but did

Re: [PATCH v3 1/2] tpm: fix reference counting for struct tpm_chip

2021-02-05 Thread Lino Sanfilippo
On 05.02.21 at 16:58, Jason Gunthorpe wrote: eference in the first place). > > No, they are all chained together because they are all in the same > struct: > > struct tpm_chip { > struct device dev; > struct device devs; > struct cdev cdev; > struct cdev cdevs; > > dev

Re: [PATCH v3 1/2] tpm: fix reference counting for struct tpm_chip

2021-02-05 Thread Lino Sanfilippo
On 05.02.21 16:15, Jason Gunthorpe wrote: > > No, the cdev layer holds the refcount on the device while open is > being called. > > Jason > Yes, but the reference that is responsible for the chip deallocation is chip->dev which is linked to chip->cdev and represents /dev/tpm, not

Re: [PATCH v3 1/2] tpm: fix reference counting for struct tpm_chip

2021-02-05 Thread Lino Sanfilippo
Hi, On 05.02.21 03:01, James Bottomley wrote: > On Thu, 2021-02-04 at 20:44 -0500, Stefan Berger wrote: >> To clarify: When I tested this I had *both* patches applied. Without >> the patches I got the null pointer exception in tpm2_del_space(). The >> 2nd patch alone solves that issue when using

Re: [PATCH v3 1/2] tpm: fix reference counting for struct tpm_chip

2021-02-05 Thread Lino Sanfilippo
Hi Stefan, On 05.02.21 01:46, Stefan Berger wrote: > On 2/4/21 6:50 PM, Lino Sanfilippo wrote: >> Signed-off-by: Lino Sanfilippo > > Tested-by: Stefan Berger > > Steps: > > modprobe tpm_vtpm_proxy > > swtpm chardev --vtpm-proxy --tpm2 --tpmstate dir=./ & > > exec 100<>/dev/tpmrm1 > >

Re: [PATCH v3 1/2] tpm: fix reference counting for struct tpm_chip

2021-02-04 Thread Greg KH
On Fri, Feb 05, 2021 at 12:50:42AM +0100, Lino Sanfilippo wrote: > From: Lino Sanfilippo > > The following sequence of operations results in a refcount warning: > > 1. Open device /dev/tpmrm > 2. Remove module tpm_tis_spi > 3. Write a TPM command to the file descriptor opened at step 1. > >

Re: [PATCH v3 1/2] tpm: fix reference counting for struct tpm_chip

2021-02-04 Thread James Bottomley
On Thu, 2021-02-04 at 20:44 -0500, Stefan Berger wrote: > To clarify: When I tested this I had *both* patches applied. Without > the patches I got the null pointer exception in tpm2_del_space(). The > 2nd patch alone solves that issue when using the steps above. Yes, I can't confirm the bug

Re: [PATCH v3 1/2] tpm: fix reference counting for struct tpm_chip

2021-02-04 Thread Stefan Berger
On 2/4/21 7:46 PM, Stefan Berger wrote: On 2/4/21 6:50 PM, Lino Sanfilippo wrote: From: Lino Sanfilippo The following sequence of operations results in a refcount warning: 1. Open device /dev/tpmrm 2. Remove module tpm_tis_spi 3. Write a TPM command to the file descriptor opened at step 1.

Re: [PATCH v3 1/2] tpm: fix reference counting for struct tpm_chip

2021-02-04 Thread Stefan Berger
On 2/4/21 6:50 PM, Lino Sanfilippo wrote: From: Lino Sanfilippo The following sequence of operations results in a refcount warning: 1. Open device /dev/tpmrm 2. Remove module tpm_tis_spi 3. Write a TPM command to the file descriptor opened at step 1. [ cut here ]

[PATCH v3 1/2] tpm: fix reference counting for struct tpm_chip

2021-02-04 Thread Lino Sanfilippo
From: Lino Sanfilippo The following sequence of operations results in a refcount warning: 1. Open device /dev/tpmrm 2. Remove module tpm_tis_spi 3. Write a TPM command to the file descriptor opened at step 1. [ cut here ] WARNING: CPU: 3 PID: 1161 at lib/refcount.c:25