Re: [tpmdd-devel] [PATCH RFC v2 5/5] tpm2: expose resource manager via a device link /dev/tpms

2017-01-16 Thread Jason Gunthorpe
On Fri, Jan 13, 2017 at 05:10:30PM -0800, James Bottomley wrote: > > No, it is correct as is. The cdev fops rely only on the tpm module. > > When tpm_chip_unregister returns to the driver the chips->ops is set > > to NULL with proper locking - the driver code becomes uncallable at > > that point.

Re: [tpmdd-devel] [PATCH RFC v2 5/5] tpm2: expose resource manager via a device link /dev/tpms

2017-01-16 Thread Jarkko Sakkinen
On Fri, Jan 13, 2017 at 09:40:08AM -0800, James Bottomley wrote: > On Fri, 2017-01-13 at 10:25 -0700, Jason Gunthorpe wrote: > > On Thu, Jan 12, 2017 at 10:56:28PM +0200, Jarkko Sakkinen wrote: > > > > > > dev_t tpm_devt; > > > > > > But they should have different major device numbers. > > > >

Re: [tpmdd-devel] [PATCH RFC v2 5/5] tpm2: expose resource manager via a device link /dev/tpms

2017-01-13 Thread James Bottomley
On Fri, 2017-01-13 at 14:23 -0700, Jason Gunthorpe wrote: > On Fri, Jan 13, 2017 at 12:02:36PM -0800, James Bottomley wrote: > > > > Actually, no, the devrm is a completely lifetime managed device > > > > as part of the chip structure. once you've done a device_del > > > > on it, it can be kfree

Re: [tpmdd-devel] [PATCH RFC v2 5/5] tpm2: expose resource manager via a device link /dev/tpms

2017-01-13 Thread Jason Gunthorpe
On Fri, Jan 13, 2017 at 12:02:36PM -0800, James Bottomley wrote: > > > Actually, no, the devrm is a completely lifetime managed device as > > > part > > > of the chip structure. once you've done a device_del on it, it can > > > be > > > kfreed because it's no longer visible to anything else. > >

Re: [tpmdd-devel] [PATCH RFC v2 5/5] tpm2: expose resource manager via a device link /dev/tpms

2017-01-13 Thread James Bottomley
On Fri, 2017-01-13 at 12:47 -0700, Jason Gunthorpe wrote: > On Fri, Jan 13, 2017 at 11:20:47AM -0800, James Bottomley wrote: > > On Thu, 2017-01-12 at 11:39 -0700, Jason Gunthorpe wrote: > > > On Thu, Jan 12, 2017 at 07:46:08PM +0200, Jarkko Sakkinen wrote: > > > > > > > struct tpm_chip { > > > >

Re: [tpmdd-devel] [PATCH RFC v2 5/5] tpm2: expose resource manager via a device link /dev/tpms

2017-01-13 Thread Jason Gunthorpe
On Fri, Jan 13, 2017 at 11:20:47AM -0800, James Bottomley wrote: > On Thu, 2017-01-12 at 11:39 -0700, Jason Gunthorpe wrote: > > On Thu, Jan 12, 2017 at 07:46:08PM +0200, Jarkko Sakkinen wrote: > > > > > struct tpm_chip { > > > - struct device dev; > > > - struct cdev cdev; > > > + struct device

Re: [tpmdd-devel] [PATCH RFC v2 5/5] tpm2: expose resource manager via a device link /dev/tpms

2017-01-13 Thread James Bottomley
On Thu, 2017-01-12 at 11:39 -0700, Jason Gunthorpe wrote: > On Thu, Jan 12, 2017 at 07:46:08PM +0200, Jarkko Sakkinen wrote: > > > struct tpm_chip { > > - struct device dev; > > - struct cdev cdev; > > + struct device dev, devrm; > > Hum.. devrm adds a new kref but doesn't do anything with

Re: [tpmdd-devel] [PATCH RFC v2 5/5] tpm2: expose resource manager via a device link /dev/tpms

2017-01-13 Thread James Bottomley
On Fri, 2017-01-13 at 11:01 -0700, Jason Gunthorpe wrote: > On Fri, Jan 13, 2017 at 09:40:08AM -0800, James Bottomley wrote: > > On Fri, 2017-01-13 at 10:25 -0700, Jason Gunthorpe wrote: > > > On Thu, Jan 12, 2017 at 10:56:28PM +0200, Jarkko Sakkinen wrote: > > > > > > > > dev_t tpm_devt; > > > >

Re: [tpmdd-devel] [PATCH RFC v2 5/5] tpm2: expose resource manager via a device link /dev/tpms

2017-01-13 Thread Jason Gunthorpe
On Fri, Jan 13, 2017 at 09:40:08AM -0800, James Bottomley wrote: > On Fri, 2017-01-13 at 10:25 -0700, Jason Gunthorpe wrote: > > On Thu, Jan 12, 2017 at 10:56:28PM +0200, Jarkko Sakkinen wrote: > > > > > > dev_t tpm_devt; > > > > > > But they should have different major device numbers. > > > >

Re: [tpmdd-devel] [PATCH RFC v2 5/5] tpm2: expose resource manager via a device link /dev/tpms

2017-01-13 Thread James Bottomley
On Fri, 2017-01-13 at 10:25 -0700, Jason Gunthorpe wrote: > On Thu, Jan 12, 2017 at 10:56:28PM +0200, Jarkko Sakkinen wrote: > > > > dev_t tpm_devt; > > > > But they should have different major device numbers. > > major/minors don't really matter these days since they are dynamic Right, althou

Re: [PATCH RFC v2 5/5] tpm2: expose resource manager via a device link /dev/tpms

2017-01-13 Thread Jason Gunthorpe
On Thu, Jan 12, 2017 at 10:56:28PM +0200, Jarkko Sakkinen wrote: > > dev_t tpm_devt; > > But they should have different major device numbers. major/minors don't really matter these days since they are dynamic Jason

Re: [PATCH RFC v2 5/5] tpm2: expose resource manager via a device link /dev/tpms

2017-01-12 Thread Jarkko Sakkinen
On Thu, Jan 12, 2017 at 07:46:08PM +0200, Jarkko Sakkinen wrote: > From: James Bottomley > > Currently the Resource Manager (RM) is not exposed to userspace. Make > this exposure via a separate device, which can now be opened multiple > times because each read/write transaction goes separately v

Re: [tpmdd-devel] [PATCH RFC v2 5/5] tpm2: expose resource manager via a device link /dev/tpms

2017-01-12 Thread James Bottomley
On Thu, 2017-01-12 at 19:46 +0200, Jarkko Sakkinen wrote: > From: James Bottomley > > Currently the Resource Manager (RM) is not exposed to userspace. > Make > this exposure via a separate device, which can now be opened multiple > times because each read/write transaction goes separately via t

Re: [PATCH RFC v2 5/5] tpm2: expose resource manager via a device link /dev/tpms

2017-01-12 Thread Jason Gunthorpe
On Thu, Jan 12, 2017 at 07:46:08PM +0200, Jarkko Sakkinen wrote: > struct tpm_chip { > - struct device dev; > - struct cdev cdev; > + struct device dev, devrm; Hum.. devrm adds a new kref but doesn't do anything with the release function, so that is going to use after free, ie here:

[PATCH RFC v2 5/5] tpm2: expose resource manager via a device link /dev/tpms

2017-01-12 Thread Jarkko Sakkinen
From: James Bottomley Currently the Resource Manager (RM) is not exposed to userspace. Make this exposure via a separate device, which can now be opened multiple times because each read/write transaction goes separately via the RM. Concurrency is protected by the chip->tpm_mutex for each read/w