Re: GPF at fsnotify_clear_marks_by_group_flags()

2013-06-07 Thread Lino Sanfilippo
On 03.06.2013 10:03, Tommi Rantala wrote: Hello, Hit this while fuzzing v3.10-rc4-0-gd683b96 with trinity. Looks similar to what I reported back in March: https://lkml.org/lkml/2013/3/13/222 Tommi [42279.088045] general protection fault: [#1] SMP DEBUG_PAGEALLOC [42279.091904] CPU: 1 PID

[PATCH 1/5] fanotify: Fix races when adding/removing marks

2013-06-09 Thread Lino Sanfilippo
. Signed-off-by: Lino Sanfilippo --- fs/notify/fanotify/fanotify_user.c | 49 +++- 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index 5d84442..213f0a1 100644 --- a/fs/notify

filesystem notification fixes/cleanup

2013-06-09 Thread Lino Sanfilippo
Hi, this patch series fixes a couple of races (fanotify/inotify) or simplifies code (dnotify) by means of the fsnotify groups mark mutex. The last patch updates the comments in fs/notify/mark.c concerning the changed fsnotify locking implementation. Regards, Lino [PATCH 1/5] fanotify: Fix races

[PATCH 2/5] fanotify: Put duplicate code for adding vfsmount/inode marks into an own function

2013-06-09 Thread Lino Sanfilippo
The code under the groups mark_mutex in fanotify_add_inode_mark() and fanotify_add_vfsmount_mark() is almost identical. So put it into a seperate function. Signed-off-by: Lino Sanfilippo --- fs/notify/fanotify/fanotify_user.c | 71 ++-- 1 file changed, 35

[PATCH 4/5] inotify: fix race when adding a new watch

2013-06-09 Thread Lino Sanfilippo
this is also synchronized by the groups mark mutex now. Signed-off-by: Lino Sanfilippo --- fs/notify/inotify/inotify_user.c | 13 - 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c index e0f7c12..14d7786

[PATCH 5/5] fsnotify: update comments concerning locking scheme

2013-06-09 Thread Lino Sanfilippo
There has been changes in the locking scheme of fsnotify but the comments in the source code have not been updated yet. This patch corrects this. Signed-off-by: Lino Sanfilippo --- fs/notify/mark.c | 50 ++ 1 file changed, 22 insertions(+), 28

[PATCH 3/5] dnotify: replace dnotify_mark_mutex with mark mutex of dnotify_group

2013-06-09 Thread Lino Sanfilippo
There is no need to use a special mutex to protect against the fcntl/close race (see dnotify.c for a description of this race). Instead the dnotify_groups mark mutex can be used. Signed-off-by: Lino Sanfilippo --- fs/notify/dnotify/dnotify.c | 25 + 1 file changed, 13

Re: [patch] fsnotify: potential use after free

2013-07-22 Thread Lino Sanfilippo
On 22.07.2013 08:53, Dan Carpenter wrote: My static checker complains that if we drop the last reference then it would be a use after free. I don't know if it's possible, but really the atomic_dec(&group->num_marks); should be done while we are holding a reference to "group". Signed-off-by: Dan

Aw: Re: BUG: Wrong dma queue handling in ixp4 driver

2016-07-22 Thread Lino Sanfilippo
Hi Krzysztof, > > Not really: there is one pool for all ports, but each port uses > a separate desc_tab (allocated from that pool). right, but even then using a dma pool seems to be a bit of overhead for only a few allocations. As far as I understood those pools are meant for hundrets or thousa

Slicoss fixes and improvements

2016-07-22 Thread Lino Sanfilippo
Hi, this patch series tries to get the slicoss driver code closer to a state in which it is ready to be moved out of staging. Patch 1 is a resend of patch I sent a week ago and handles an allocation failure in slic_init_adapter(). Patch 2 fixes link state notification. Patch 3 turns the mapping

[PATCH 3/9] staging: slicoss: ensure mapping of io-memory is uncached

2016-07-22 Thread Lino Sanfilippo
From: Lino Sanfilippo Writes to registers should be done uncached for various reasons. Ensure this by replacing ioremap() with ioremap_nocache(). Signed-off-by: Lino Sanfilippo --- drivers/staging/slicoss/slicoss.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers

[PATCH 6/9] staging: slicoss: avoid PCI write posting

2016-07-22 Thread Lino Sanfilippo
Introduce the function slic_flush_write() which reads from the HOSTID register and can be used to avoid PCI write posting. Use the function at several critical places in the code. Signed-off-by: Lino Sanfilippo --- drivers/staging/slicoss/slic.h| 5 + drivers/staging/slicoss/slicoss.c

[PATCH 4/9] staging: slicoss: start tx queue when interface is brought up

2016-07-22 Thread Lino Sanfilippo
There is no reason to delay tx queue activation until a link is detected. So start the queue when the interface is brought up and stop it when the interface is brought down. Signed-off-by: Lino Sanfilippo --- drivers/staging/slicoss/slicoss.c | 5 +++-- 1 file changed, 3 insertions(+), 2

[PATCH 2/9] staging: slicoss: notifiy network stack about change in link state

2016-07-22 Thread Lino Sanfilippo
Notify the network stack about link states via netif_carrier_[off|on](). Also set the link state off initially and when the interface is brought down. Signed-off-by: Lino Sanfilippo --- drivers/staging/slicoss/slicoss.c | 8 1 file changed, 8 insertions(+) diff --git a/drivers/staging

[PATCH 1/9] staging: slicoss: handle allocation failure in slic_init_adapter

2016-07-22 Thread Lino Sanfilippo
a zalloc() version. Signed-off-by: Lino Sanfilippo --- drivers/staging/slicoss/slicoss.c | 38 ++ 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index ac126d4..dae07410

[PATCH 7/9] staging: slicoss: dont use a structure but offsets for register accesses

2016-07-22 Thread Lino Sanfilippo
Use the new register accessors that use offsets instead of the slic_regs structure to read/write registers. Since not longer needed remove the structure completley. Signed-off-by: Lino Sanfilippo --- drivers/staging/slicoss/slic.h| 1 - drivers/staging/slicoss/slichw.h | 219

[PATCH 8/9] staging: slicoss: improve implementation concerning the shared memory

2016-07-22 Thread Lino Sanfilippo
-off-by: Lino Sanfilippo --- drivers/staging/slicoss/slic.h| 18 ++- drivers/staging/slicoss/slicoss.c | 267 ++ 2 files changed, 136 insertions(+), 149 deletions(-) diff --git a/drivers/staging/slicoss/slic.h b/drivers/staging/slicoss/slic.h index 3bba82a

[PATCH 5/9] staging: slicoss: introduce register accessors that use register offsets

2016-07-22 Thread Lino Sanfilippo
Introduce accessor functions that read and write registers by using a register offset. This is in preparation to replace the register addressing by means of the slic_regs struct with an addressing by means of offsets. Signed-off-by: Lino Sanfilippo --- drivers/staging/slicoss/slic.h| 24

[PATCH 9/9] staging: slicoss: simplify struct for statistics

2016-07-22 Thread Lino Sanfilippo
Merge several structures for statistics to one structure and remove unnecessary union nesting. Signed-off-by: Lino Sanfilippo --- drivers/staging/slicoss/slic.h| 18 + drivers/staging/slicoss/slichw.h | 79 --- drivers/staging/slicoss/slicoss.c

Aw: Re: staging: wilc1000: Reduce scope for a few variables in mac_ioctl()

2016-07-28 Thread Lino Sanfilippo
> Gesendet: Dienstag, 26. Juli 2016 um 08:25 Uhr > Von: "SF Markus Elfring" > > >> - if (strncasecmp(buff, "RSSI", length) == 0) { > >> + if (strncasecmp(buff, "RSSI", 0) == 0) { > >> + s8 rssi; > >> + > > > > Um, please think a second

Re: [PATCH] net: ethernet: slicoss: remove redundant initialization of idx

2017-10-30 Thread Lino Sanfilippo
-355,7 +355,7 @@ static void slic_xmit_complete(struct slic_device *sdev) > { > struct slic_tx_queue *txq = &sdev->txq; > struct net_device *dev = sdev->netdev; > - unsigned int idx = txq->done_idx; > + unsigned int idx; > struct slic_tx_buff

Re: [PATCH] net: ethernet: slicoss: remove redundant initialization of idx

2017-10-30 Thread Lino Sanfilippo
On 30.10.2017 19:04, Jakub Kicinski wrote: > On Sun, 29 Oct 2017 13:38:09 +, Colin King wrote: >> From: Colin Ian King >> >> Variable idx is being initialized and later on over-written by >> a new value in a do-loop without the initial value ever being >> read. Hence the initializion is redund

Re: [PATCH][V2] net: ethernet: slicoss: remove redundant initialization of idx

2017-10-31 Thread Lino Sanfilippo
frames = 0; > unsigned int bytes = 0; > + unsigned int idx; > > /* Limit processing to SLIC_MAX_TX_COMPLETIONS frames to avoid that new >* completions during processing keeps the loop running endlessly. > Acked-by: Lino Sanfilippo Regards, Lino

Re: [PATCH][V2] ethernet: aquantia: remove redundant checks on error status

2017-05-11 Thread Lino Sanfilippo
gt; > Detected by CoverityScan, CID#1398313 and CID#1398306 ("Logically > dead code") > > Signed-off-by: Colin Ian King FWIW: Reviewed-by: Lino Sanfilippo Regards, Lino

Re: [PATCH v5 17/17] net: qualcomm: add QCA7000 UART driver

2017-05-11 Thread Lino Sanfilippo
Hi, On 10.05.2017 10:53, Stefan Wahren wrote: > +static int qcauart_netdev_init(struct net_device *dev) > +{ > + struct qcauart *qca = netdev_priv(dev); > + size_t len; > + > + /* Finish setting up the device info. */ > + dev->mtu = QCAFRM_MAX_MTU; > + dev->type = ARPHRD_ETHER

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-

[PATCH v4] TPM fixes

2021-02-15 Thread Lino Sanfilippo
detailed - add fixes tags and kernel logs Lino Sanfilippo (1): tpm: fix reference counting for struct tpm_chip drivers/char/tpm/tpm-chip.c | 80 - 1 file changed, 50 insertions(+), 30 deletions(-) -- 2.7.4

[PATCH v4] tpm: fix reference counting for struct tpm_chip

2021-02-15 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

Re: [PATCH v4] tpm: fix reference counting for struct tpm_chip

2021-02-16 Thread Lino Sanfilippo
Hi, On 16.02.21 at 13:53, Jason Gunthorpe wrote: > On Tue, Feb 16, 2021 at 01:31:00AM +0100, Lino Sanfilippo wrote: >> >> +static int tpm_add_tpm2_char_device(struct tpm_chip *chip) >> +{ >> +int rc; >> + >> +device_initialize(&chip->devs)

Re: [PATCH v4] tpm: fix reference counting for struct tpm_chip

2021-02-16 Thread Lino Sanfilippo
ue, Feb 16, 2021 at 01:31:00AM +0100, Lino Sanfilippo wrote: >>>>> >>>>> +static int tpm_add_tpm2_char_device(struct tpm_chip *chip) >>> >>> BTW, this naming is crap. >>> >>> - 2x tpm >>> - char is useless >>

Re: [PATCH v4] tpm: fix reference counting for struct tpm_chip

2021-02-16 Thread Lino Sanfilippo
Hi On 16.02.21 at 17:04, Jarkko Sakkinen wrote: >>> + /* >>> +* get extra reference on main device to hold on behalf of devs. >>> +* This holds the chip structure while cdevs is in use. The >>> +* corresponding put is in the tpm_devs_release. >>> +*/ >>> + get_device(&chip->de

Re: [PATCH v4] tpm: fix reference counting for struct tpm_chip

2021-02-16 Thread Lino Sanfilippo
Hi Stefan, On 16.02.21 at 17:52, Stefan Berger wrote: > On 2/15/21 7:31 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_t

[PATCH v5] TPM fixes

2021-02-16 Thread Lino Sanfilippo
rkko Sakkinen) - make the commit message for patch 1 more detailed - add fixes tags and kernel logs Lino Sanfilippo (1): The following sequence of operations results in a refcount warning: drivers/char/tpm/tpm-chip.c | 48 +-- drivers/char/tpm/tpm.

[PATCH v5] The following sequence of operations results in a refcount warning:

2021-02-16 Thread Lino Sanfilippo
From: Lino Sanfilippo 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 kobject_get+0xa0/0xa4 refcount_t: addition on 0; use-after-free

Re: [PATCH v5] The following sequence of operations results in a refcount warning:

2021-02-16 Thread Lino Sanfilippo
Please ignore this patch, I somehow managed to cut off the head line. I will resend it shorty. Regards, Lino

[PATCH RESEND v5] TPM fixes

2021-02-16 Thread Lino Sanfilippo
rkko Sakkinen) - make the commit message for patch 1 more detailed - add fixes tags and kernel logs Lino Sanfilippo (1): tpm: fix reference counting for struct tpm_chip drivers/char/tpm/tpm-chip.c | 48 +-- drivers/char/tpm/tpm.h| 1 + drivers/

[PATCH RESEND v5] tpm: fix reference counting for struct tpm_chip

2021-02-16 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

[PATCH v3 1/3] fanotify: only destroy mark when both mask and ignored_mask are cleared

2014-12-06 Thread Lino Sanfilippo
In fanotify_mark_remove_from_mask() a mark is destroyed if only one of both bitmasks (mask or ignored_mask) of a mark is cleared. However the other mask may still be set and contain information that should not be lost. So only destroy a mark if both masks are cleared. Signed-off-by: Lino

[PATCH v3 2/3] fanotify: dont recalculate a marks mask if only the ignored mask changed

2014-12-06 Thread Lino Sanfilippo
If removing bits from a marks ignored mask, the concerning inodes/vfsmounts mask is not affected. So dont recalculate it. Signed-off-by: Lino Sanfilippo Reviewed-by: Jan Kara --- fs/notify/fanotify/fanotify_user.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs

[PATCH v3 3/3] fanotify: dont set FAN_ONDIR implicitly on a marks ignored mask

2014-12-06 Thread Lino Sanfilippo
ent flag and require FAN_MARK_ONDIR to be set by the user for both event mask and ignore mask. Furthermore take FAN_MARK_ONDIR into account when set for event removal. Signed-off-by: Lino Sanfilippo Reviewed-by: Jan Kara --- fs/notify/fanotify/fanotify.c | 2 +- fs/notify/fanotify/

Re: [PATCH 1/1 linux-next] fanotify: fix a lock in fanotify_should_send_event()

2015-03-20 Thread Lino Sanfilippo
Hi, On 20.03.2015 21:56, Fabian Frederick wrote: > ltp/fanotify02 was locked since commit 66ba93c0d7fe > ("fanotify: don't set FAN_ONDIR implicitly on a marks ignored mask") > > Signed-off-by: Fabian Frederick > --- > fs/notify/fanotify/fanotify.c | 4 ++-- > 1 file changed, 2 insertions(+), 2

Re: [PATCH 1/1 linux-next] fanotify: fix a lock in fanotify_should_send_event()

2015-03-20 Thread Lino Sanfilippo
On 20.03.2015 22:09, Andrew Morton wrote: > On Fri, 20 Mar 2015 21:56:08 +0100 Fabian Frederick wrote: > >> ltp/fanotify02 was locked since commit 66ba93c0d7fe >> ("fanotify: don't set FAN_ONDIR implicitly on a marks ignored mask") > > What does "ltp/fanotify02 was locked" mean? That this parti

Re: [PATCH 1/1 linux-next] fanotify: fix a lock in fanotify_should_send_event()

2015-03-20 Thread Lino Sanfilippo
On 21.03.2015 02:01, Lino Sanfilippo wrote: >> Should that be (marks_mask & FS_ISDIR & marks_ignored_mask)? >> > > No, the current logic should be correct, since we want events for > directories if we have FS_ISDIR set in the marks mask but not in its > ignored_m

Re: [RFC PATCH 0/1] Wrong structure alignment due to compiler attribute "section"

2015-03-21 Thread Lino Sanfilippo
On 06.03.2015 19:20, Lino Sanfilippo wrote: > >>> >> >> Ok, I got a link to the source now. It can be found here: >> >> http://tp-lab200/release/gcc/temp/internal/2010q4-113-4.4.5/marvell-gcc.src-2010q4-113.tar.bz2 >> > > > Sigh. Just reali

Re: [PATCH 1/1 linux-next] fanotify: fix a lock in fanotify_should_send_event()

2015-03-22 Thread Lino Sanfilippo
On 22.03.2015 10:46, Fabian Frederick wrote: > Let's hope it only breaks ltp tests and no _real_ userland stuff > (search systems ...) > > Regards, > Fabian > Hi Fabian, yes, that worries me too. I know that there have been discussions on lkml in which it was made clear that userspace breakage

Re: [LKP] [fanotify] 66ba93c0d7f: i6300esb: Unexpected close, not stopping watchdog!

2015-04-24 Thread Lino Sanfilippo
On 24.04.2015 19:42, Andrew Morton wrote: > On Thu, 23 Apr 2015 14:25:38 +0800 Huang Ying wrote: > >> FYI, we noticed the below changes on >> >> git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master >> commit 66ba93c0d7fe63def447ad0afe380307ff9ebcad ("fanotify: don't set >> FA

Aw: Re: [PATCH] net: iucv: Free memory obtained by kzalloc

2018-02-28 Thread Lino Sanfilippo
Hi, > On Wednesday 28 February 2018 05:26 PM, Cornelia Huck wrote: > > On Wed, 28 Feb 2018 17:14:55 +0530 > > Arvind Yadav wrote: > > > >> On Wednesday 28 February 2018 04:00 PM, Cornelia Huck wrote: > >>> On Wed, 28 Feb 2018 15:24:16 +0530 > >>> Arvind Yadav wrote: > >>> > Free memory,

Re: [PATCH RESEND v5] tpm: fix reference counting for struct tpm_chip

2021-02-18 Thread Lino Sanfilippo
Hi, On 17.02.21 at 23:18, Jarkko Sakkinen wrote: >> + > > /* > * Please describe what the heck the function does. No need for full on > * kdoc. > */ Ok. >> +int tpm2_add_device(struct tpm_chip *chip) > > Please, rename as tpm_devs_add for coherency sake. > Sorry I confused this and rename

[PATCH v6] tpm: fix reference counting for struct tpm_chip

2021-02-18 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

[PATCH v6] TPM fixes

2021-02-18 Thread Lino Sanfilippo
t Changes in v2: - drop the patch that erroneously cleaned up after failed installation of an action handler in tpmm_chip_alloc() (pointed out by Jarkko Sakkinen) - make the commit message for patch 1 more detailed - add fixes tags and kernel logs Lino Sanfilippo (1): tpm: fix reference counti

[PATCH v2 3/3] tpm: in tpm2_del_space check if ops pointer is still valid

2021-02-02 Thread Lino Sanfilippo
From: Lino Sanfilippo In tpm2_del_space() the sessions are flushed by means of the tpm_chip operations. However the concerning operations pointer my already be NULL at this time in case that the chip has been unregistered (see tpm_chip_unregister() which calls tpm_del_char_device() which sets

[PATCH v2 0/3] TPM fixes

2021-02-02 Thread Lino Sanfilippo
v2: - drop the patch that erroneously cleaned up after failed installation of an action handler ni tpmm_chip_alloc() (pointed out by Jarkko Sakkinen) - make the commit message for patch 1 more detailed - add fixes tags and kernel logs Lino Sanfilippo (3): tpm: fix reference counting for struct

[PATCH v2 1/3] tpm: fix reference counting for struct tpm_chip

2021-02-02 Thread Lino Sanfilippo
From: Lino Sanfilippo The following sequence of operations 1. open device /dev/tpmrm 2. remove the registered tpm chip driver 3. perform a write() to /dev/tpmrm results in a refcount warning: [ cut here ] WARNING: CPU: 3 PID: 1161 at lib/refcount.c:25 kobject_get+0xa0

[PATCH v2 2/3] tpm: Provide a function tpm_chip_free() to free tpm chips

2021-02-02 Thread Lino Sanfilippo
From: Lino Sanfilippo Provide a function tpm_chip_free() as a counterpart to tpm_chip_alloc(). The function hides the internals of freeing a struct tpm_chip instance by putting the device references which are part of this structure. Use the new function at the appropriate places. Signed-off-by

Re: [PATCH v2 1/3] tpm: fix reference counting for struct tpm_chip

2021-02-03 Thread Lino Sanfilippo
Hi, On 03.02.21 02:09, Jarkko Sakkinen wrote: > On Tue, Feb 02, 2021 at 11:09:01PM +0100, Lino Sanfilippo wrote: >> From: Lino Sanfilippo >> >> The following sequence of operations >> >> 1. open device /dev/tpmrm >> 2. remove the registered tpm chip driver

Re: [PATCH v2 2/3] tpm: Provide a function tpm_chip_free() to free tpm chips

2021-02-03 Thread Lino Sanfilippo
Hi On 03.02.21 02:28, Jarkko Sakkinen wrote: > On Tue, Feb 02, 2021 at 11:09:02PM +0100, Lino Sanfilippo wrote: >> From: Lino Sanfilippo >> >> Provide a function tpm_chip_free() as a counterpart to tpm_chip_alloc(). >> The function hides the internals of freeing a str

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

2021-02-03 Thread Lino Sanfilippo
Hi, On 03.02.21 02:17, Jarkko Sakkinen wrote: > On Tue, Feb 02, 2021 at 11:09:03PM +0100, Lino Sanfilippo wrote: >> From: Lino Sanfilippo >> >> In tpm2_del_space() the sessions are flushed by means of the tpm_chip >> operations. However the concerning operations po

[PATCH v3 0/2] TPM fixes

2021-02-04 Thread Lino Sanfilippo
cleaned up after failed installation of an action handler in tpmm_chip_alloc() (pointed out by Jarkko Sakkinen) - make the commit message for patch 1 more detailed - add fixes tags and kernel logs Lino Sanfilippo (2): tpm: fix reference counting for struct tpm_chip tpm: in tpm2_del_space check if

[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 acc

[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

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

2021-02-05 Thread Lino Sanfilippo
slightly better than it had been done previously. I tested your patch and it fixes the issue. Your solution seems indeed much cleaner. FWIW: Tested-by: Lino Sanfilippo Best Regards, Lino

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 di

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 t

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 /dev/tpmrm.

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-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

Aw: Re: [PATCH v3] pwm: bcm2835: Support apply function for atomic configuration

2020-12-11 Thread Lino Sanfilippo
Hi Uwe, > Gesendet: Donnerstag, 10. Dezember 2020 um 12:43 Uhr > Von: "Uwe Kleine-König" > An: "Lino Sanfilippo" > Cc: thierry.red...@gmail.com, lee.jo...@linaro.org, nsaenzjulie...@suse.de, > f.faine...@gmail.com, r...@broadcom.com, s...@mess.org, > sbra

Re: [PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

2020-12-07 Thread Lino Sanfilippo
Hi, On 07.12.20 at 14:52, Uwe Kleine-König wrote: > > Given that the bcm2835 driver is quite trivial I would be happy to > create a series that "fixes" the driver to round down and provide a > prototype for pwm_round_nearest for you to test on pwm-ir-tx. A willing > tester and a real use-case wer

[PATCH v3] pwm: bcm2835: Support apply function for atomic configuration

2020-12-08 Thread Lino Sanfilippo
possible max value for the 32 bit register. This has been tested on a Raspberry PI 4. Signed-off-by: Lino Sanfilippo --- v3: Check against period truncation (based on a review by Uwe Kleine-König) v2: Fix compiler error for 64 bit builds drivers/pwm/pwm-bcm2835.c | 72

Re: [PATCH v6] tpm: fix reference counting for struct tpm_chip

2021-02-21 Thread Lino Sanfilippo
Hi, On 19.02.21 at 10:13, Jarkko Sakkinen wrote: >> +rc = cdev_device_add(&chip->cdevs, &chip->devs); >> +if (rc) { >> +dev_err(&chip->devs, >> +"unable to cdev_device_add() %s, major %d, minor %d, >> err=%d\n", >> +dev_name(&chip->de

[PATCH v7] TPM fixes

2021-02-21 Thread Lino Sanfilippo
etailed - add fixes tags and kernel logs Lino Sanfilippo (1): tpm: fix reference counting for struct tpm_chip drivers/char/tpm/tpm-chip.c | 48 - drivers/char/tpm/tpm.h| 1 + drivers/char/tpm/tpm2-space.c | 55 +

[PATCH v7] tpm: fix reference counting for struct tpm_chip

2021-02-21 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

[PATCH 0/4] Fixes for TPM interrupt handling

2021-02-21 Thread Lino Sanfilippo
Lino Sanfilippo (4): tpm: Use a threaded interrupt handler tpm: get locality before writing to TPM chip tpm: Fix test for interrupts tpm: Only enable supported irqs drivers/char/tpm/tpm-chip.c | 10 drivers/char/tpm/tpm_tis_core.c | 127

[PATCH 2/4] tpm: get locality before writing to TPM chip

2021-02-21 Thread Lino Sanfilippo
driver startup and only release it at driver shutdown. Signed-off-by: Lino Sanfilippo --- drivers/char/tpm/tpm-chip.c | 10 -- drivers/char/tpm/tpm_tis_core.c | 16 +--- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char

[PATCH 4/4] tpm: Only enable supported irqs

2021-02-21 Thread Lino Sanfilippo
Do not set interrupts which are not supported by the hardware. Instead use the information from the capability query and activate only the reported interrupts. Signed-off-by: Lino Sanfilippo --- drivers/char/tpm/tpm_tis_core.c | 68 ++--- drivers/char/tpm

[PATCH 3/4] tpm: Fix test for interrupts

2021-02-21 Thread Lino Sanfilippo
visibility between the interrupt handler and threads. Finally remove one function which is no longer needed. Signed-off-by: Lino Sanfilippo --- drivers/char/tpm/tpm_tis_core.c | 37 ++--- drivers/char/tpm/tpm_tis_core.h | 1 - include/linux/tpm.h | 2

[PATCH 1/4] tpm: Use a threaded interrupt handler

2021-02-21 Thread Lino Sanfilippo
. Signed-off-by: Lino Sanfilippo --- drivers/char/tpm/tpm_tis_core.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index 92c51c6..2c956a1 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm

Aw: Re: [PATCH v3] pwm: bcm2835: Support apply function for atomic configuration

2020-12-09 Thread Lino Sanfilippo
Hi Uwe > Hello Lino, > > On Tue, Dec 08, 2020 at 11:01:45PM +0100, Lino Sanfilippo wrote: > > Use the newer .apply function of pwm_ops instead of .config, .enable, > > .disable and .set_polarity. This guarantees atomic changes of the pwm > > controller configuration.

[PATCH v4] pwm: bcm2835: Support apply function for atomic configuration

2020-12-09 Thread Lino Sanfilippo
possible max value for the 32 bit register. This has been tested on a Raspberry PI 4. Signed-off-by: Lino Sanfilippo --- v4: Remove a superfluous blank line Remove an unneeded cast (both requested by Uwe Kleine-König) v3: Check against period truncation (also based on a review by Uwe) v2: Fix

Re: [PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

2020-12-04 Thread Lino Sanfilippo
Hi Sean, On 04.12.20 at 09:44, Sean Young wrote: >> What about an extra check then to make sure that the period has not been >> truncated, >> e.g: >> >> value = DIV_ROUND_CLOSEST_ULL(state->period, scaler); >> >> /* dont accept a period that is too small or has been truncated */ >>

Re: [PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

2020-12-04 Thread Lino Sanfilippo
Hi, On 04.12.20 at 12:21, Uwe Kleine-König wrote: > > I'd make value an unsigned long long and check for > 0x instead > of repeating the (expensive) division. (Hmm, maybe the compiler is smart > enough to not actually repeat it, but still.) I also prefer unsigned long long over u64 sinc

Re: [PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

2020-12-03 Thread Lino Sanfilippo
Hi Uwe, First off, thanks for the review! On 29.11.20 at 19:10, Uwe Kleine-König wrote: > > Changelog between review rounds go to below the tripple-dash below. > Right, will do so in the next patch version. > > You're storing an unsigned long long (i.e. 64 bits) in an u32. If > you are sure

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

2021-03-06 Thread Lino Sanfilippo
ted your patch and it fixes the issue. Your solution seems indeed much > cleaner. > > FWIW: > > Tested-by: Lino Sanfilippo > Are you going to send a patch for this? As stated above I verified that your solution fixes the issue. Best regards, Lino

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 holds

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

[PATCH 4/4] tpm: Provide a function tpm_chip_free() to free tpm chips

2021-01-15 Thread Lino Sanfilippo
From: Lino Sanfilippo Provide a function tpm_chip_free() as a counterpart to tpm_chip_alloc(). The function hides the internals of freeing a struct tpm_chip instance by putting the device references which are part of this structure. Use the new function at the appropriate places. Signed-off-by

[PATCH 0/4] TPM fixes

2021-01-15 Thread Lino Sanfilippo
tpm_chip_free() which is used as a counterpart to tpm_chip_alloc(). The main reason for this function is to hide the internals of tpm_chip cleanup by means of multiple reference count handling. Lino Sanfilippo (4): tpm: in case of error properly cleanup in tpmm_chip_alloc tpm: fix reference

[PATCH 1/4] tpm: in case of error properly cleanup in tpmm_chip_alloc

2021-01-15 Thread Lino Sanfilippo
From: Lino Sanfilippo In tpmm_chip_alloc() a resource management action handler is installed to release the chip->dev in case of error. This will result in the chip being freed if it was the last reference. If the installation of the handler was not successful an error is returned to the cal

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

2021-01-15 Thread Lino Sanfilippo
From: Lino Sanfilippo Commit 8979b02aaf1d ("tpm: Fix reference count to main device") tried to fix a reference count issue which prevented the tpm_chip structure from being freed in case that no TPM2 was used. The fix was to only get an extra reference for chip->dev in case of

[PATCH 3/4] tpm: in tpm2_del_space check if ops pointer is still valid

2021-01-15 Thread Lino Sanfilippo
From: Lino Sanfilippo In tpm2_del_space() the sessions are flushed by means of the tpm_chip operations. However the concerning operations pointer my already be NULL at this time in case that the chip has been unregistered (see tpm_chip_unregister() which calls tpm_del_char_device() which sets

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

2021-01-24 Thread Lino Sanfilippo
Hi Jarkko, On 17.01.21 at 19:13, Jarkko Sakkinen wrote: > > I have hard time to believe that any of these patches are based on > actual regressions. > > /Jarko > patch 1 is indeed wrong (I oversaw the action call in case of error), so please ignore it. However patches 2 and 3 are based on bugs

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

2021-01-27 Thread Lino Sanfilippo
Hi, On 26.01.21 16:29, Jarkko Sakkinen wrote: > On Sun, 2021-01-24 at 17:47 +0100, Lino Sanfilippo wrote: >> Hi Jarkko, >> >> On 17.01.21 at 19:13, Jarkko Sakkinen wrote: >>> I have hard time to believe that any of these patches are based on >>> actual reg

[PATCH] pwm: bcm2835: Support apply function for atomic configuration

2020-11-27 Thread Lino Sanfilippo
Use the newer apply function of pwm_ops instead of config, enable, disable and set_polarity. This guarantees atomic changes of the pwm controller configuration. It also reduces the size of the driver. This has been tested on a Raspberry PI 4. Signed-off-by: Lino Sanfilippo --- drivers/pwm/pwm

Re: [RESEND PATCH 1/2] iio:core: Introduce unlocked version of iio_map_array_unregister()

2020-11-28 Thread Lino Sanfilippo
Hi Jonathan, On 28.11.20 at 14:54, Jonathan Cameron wrote: > A few notes to make it harder for people to do that in future. > 1. Don't send patch series (or new versions of older patches) in reply >to an existing thread. They get lost and difficult to pull out. >b4 can't automatically f

[PATCH v2] pwm: bcm2835: Support apply function for atomic configuration

2020-11-28 Thread Lino Sanfilippo
Use the newer apply function of pwm_ops instead of config, enable, disable and set_polarity. This guarantees atomic changes of the pwm controller configuration. It also reduces the size of the driver. This has been tested on a Raspberry PI 4. v2: Fixed compiler error Signed-off-by: Lino

[RESEND PATCH 1/2] iio:core: Introduce unlocked version of iio_map_array_unregister()

2020-11-28 Thread Lino Sanfilippo
Introduce an unlocked version of iio_map_array_unregister(). This function can help to unwind in case of error while the iio_map_list_lock mutex is held. Signed-off-by: Lino Sanfilippo Reviewed-by: Andy Shevchenko --- drivers/iio/inkern.c | 27 ++- 1 file changed, 18

[RESEND PATCH 2/2] io:core: In iio_map_array_register() cleanup in case of error

2020-11-28 Thread Lino Sanfilippo
In function iio_map_array_register() properly rewind in case of error. Signed-off-by: Lino Sanfilippo Reviewed-by: Andy Shevchenko --- drivers/iio/inkern.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index 39c1d63..fe30bcb 100644 --- a

Re: [PATCH v2 1/2] net: nps_enet: Sync access to packet sent flag

2016-05-02 Thread Lino Sanfilippo
Hi Elad, On 02.05.2016 12:21, Elad Kanfi wrote: Since this driver handles one frame at a time, I couldn't find a case that requires the paired barrier. The order of reads is not critical once it is assured that the value is valid. Please see sections "SMP BARRIER PAIRING" and "EXAMPLES OF

Re: [PATCH v2 1/2] net: nps_enet: Sync access to packet sent flag

2016-05-10 Thread Lino Sanfilippo
Hi Elad, On 08.05.2016 15:44, Elad Kanfi wrote: > > After reviewing the code and your suggestion, it seems that we can do without > the flag tx_packet_sent and therefor the first issue becomes irrelevant. > The indication that a packet was sent is (tx_skb != NULL) , and the sequence > will b

Re: [PATCH v2 1/2] net: nps_enet: Sync access to packet sent flag

2016-04-27 Thread Lino Sanfilippo
Hi, On 27.04.2016 15:18, Elad Kanfi wrote: From: Elad Kanfi Below is a description of a possible problematic sequence. CPU-A is sending a frame and CPU-B handles the interrupt that indicates the frame was sent. CPU-B reads an invalid value of tx_packet_sent. CPU-A

  1   2   3   >