[PATCH 04/12] ipc: Rename ipcctl_pre_down_nolock().

2018-07-09 Thread Manfred Spraul
a pointer in the idr, without acquiring the object lock. - The caller is responsible for locking. - _check means that the sequence number is checked. Signed-off-by: Manfred Spraul Cc: Davidlohr Bueso --- ipc/msg.c | 2 +- ipc/sem.c | 2 +- ipc/shm.c | 2 +- ipc/util.c | 8 ipc/util.h | 2 +

[PATCH 12/12] ipc/util.c: Further ipc_idr_alloc cleanups.

2018-07-09 Thread Manfred Spraul
If idr_alloc within ipc_idr_alloc fails, then the return value (-ENOSPC) is used to calculate new->id. Technically, this is not a bug, because new->id is never accessed. But: Clean it up anyways: On error, just return, do not set new->id. And improve the documentation. Signed-off-by

[PATCH 03/12] ipc/util.c: Use ipc_rcu_putref() for failues in ipc_addid()

2018-07-09 Thread Manfred Spraul
-by: Manfred Spraul Cc: Dmitry Vyukov Cc: Kees Cook Cc: Davidlohr Bueso --- ipc/msg.c | 2 +- ipc/sem.c | 2 +- ipc/shm.c | 2 ++ ipc/util.c | 12 ++-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ipc/msg.c b/ipc/msg.c index 829c2062ded4..5bf5cb8017ea 100644 --- a/ipc

[PATCH 0/12 V2] ipc: cleanups & bugfixes, rhashtable update

2018-07-09 Thread Manfred Spraul
any issues in my tests. -- Manfred

[PATCH 03/12] ipc/util.c: Use ipc_rcu_putref() for failues in ipc_addid()

2018-07-09 Thread Manfred Spraul
-by: Manfred Spraul Cc: Dmitry Vyukov Cc: Kees Cook Cc: Davidlohr Bueso --- ipc/msg.c | 2 +- ipc/sem.c | 2 +- ipc/shm.c | 2 ++ ipc/util.c | 12 ++-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ipc/msg.c b/ipc/msg.c index 829c2062ded4..5bf5cb8017ea 100644 --- a/ipc

[PATCH 0/12 V2] ipc: cleanups & bugfixes, rhashtable update

2018-07-09 Thread Manfred Spraul
any issues in my tests. -- Manfred

[PATCH 05/12] ipc/util.c: correct comment in ipc_obtain_object_check

2018-07-09 Thread Manfred Spraul
=true may disappear at the end of the next rcu grace period. Signed-off-by: Manfred Spraul Cc: Davidlohr Bueso --- ipc/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ipc/util.c b/ipc/util.c index bbb1ce212a0d..8133f10832a9 100644 --- a/ipc/util.c +++ b/ipc/util.c

[PATCH 05/12] ipc/util.c: correct comment in ipc_obtain_object_check

2018-07-09 Thread Manfred Spraul
=true may disappear at the end of the next rcu grace period. Signed-off-by: Manfred Spraul Cc: Davidlohr Bueso --- ipc/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ipc/util.c b/ipc/util.c index bbb1ce212a0d..8133f10832a9 100644 --- a/ipc/util.c +++ b/ipc/util.c

[PATCH 02/12] ipc: reorganize initialization of kern_ipc_perm.seq

2018-07-09 Thread Manfred Spraul
not fullfill that, i.e. more bugfixes are required. Reported-by: syzbot+2827ef6b3385deb07...@syzkaller.appspotmail.com Signed-off-by: Manfred Spraul Cc: Dmitry Vyukov Cc: Kees Cook Cc: Davidlohr Bueso Cc: Michael Kerrisk --- Documentation/sysctl/kernel.txt | 3 ++- ipc/util.c

[PATCH 02/12] ipc: reorganize initialization of kern_ipc_perm.seq

2018-07-09 Thread Manfred Spraul
not fullfill that, i.e. more bugfixes are required. Reported-by: syzbot+2827ef6b3385deb07...@syzkaller.appspotmail.com Signed-off-by: Manfred Spraul Cc: Dmitry Vyukov Cc: Kees Cook Cc: Davidlohr Bueso Cc: Michael Kerrisk --- Documentation/sysctl/kernel.txt | 3 ++- ipc/util.c

Re: [PATCH 2/6] ipc: reorganize initialization of kern_ipc_perm.seq

2018-07-05 Thread Manfred Spraul
Hi Dmitry, On 07/05/2018 10:36 AM, Dmitry Vyukov wrote: [...] Hi Manfred, The series looks like a significant improvement to me. Thanks! I feel that this code can be further simplified (unless I am missing something here). Please take a look at this version: https://github.com/dvyukov/linux

Re: [PATCH 2/6] ipc: reorganize initialization of kern_ipc_perm.seq

2018-07-05 Thread Manfred Spraul
Hi Dmitry, On 07/05/2018 10:36 AM, Dmitry Vyukov wrote: [...] Hi Manfred, The series looks like a significant improvement to me. Thanks! I feel that this code can be further simplified (unless I am missing something here). Please take a look at this version: https://github.com/dvyukov/linux

[PATCH 3/6] ipc/util.c: Use ipc_rcu_putref() for failues in ipc_addid()

2018-07-05 Thread Manfred Spraul
-by: Manfred Spraul Cc: Dmitry Vyukov Cc: Kees Cook Cc: Davidlohr Bueso --- ipc/msg.c | 2 +- ipc/sem.c | 2 +- ipc/shm.c | 2 ++ ipc/util.c | 12 ++-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ipc/msg.c b/ipc/msg.c index 829c2062ded4..5bf5cb8017ea 100644 --- a/ipc

[PATCH 3/6] ipc/util.c: Use ipc_rcu_putref() for failues in ipc_addid()

2018-07-05 Thread Manfred Spraul
-by: Manfred Spraul Cc: Dmitry Vyukov Cc: Kees Cook Cc: Davidlohr Bueso --- ipc/msg.c | 2 +- ipc/sem.c | 2 +- ipc/shm.c | 2 ++ ipc/util.c | 12 ++-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ipc/msg.c b/ipc/msg.c index 829c2062ded4..5bf5cb8017ea 100644 --- a/ipc

[PATCH 2/6] ipc: reorganize initialization of kern_ipc_perm.seq

2018-07-05 Thread Manfred Spraul
not fullfill that, i.e. more bugfixes are required. Reported-by: syzbot+2827ef6b3385deb07...@syzkaller.appspotmail.com Signed-off-by: Manfred Spraul Cc: Dmitry Vyukov Cc: Kees Cook Cc: Davidlohr Bueso Cc: Michael Kerrisk Signed-off-by: Manfred Spraul --- Documentation/sysctl/kernel.txt | 3

[PATCH 6/6] ipc/util.c: correct comment in ipc_obtain_object_check

2018-07-05 Thread Manfred Spraul
=true may disappear at the end of the next rcu grace period. Signed-off-by: Manfred Spraul --- ipc/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ipc/util.c b/ipc/util.c index 4f2db913acf9..776a9ce2905f 100644 --- a/ipc/util.c +++ b/ipc/util.c @@ -646,8 +646,8

[PATCH 4/6] ipc: Rename ipcctl_pre_down_nolock().

2018-07-05 Thread Manfred Spraul
a pointer in the idr, without acquiring the object lock. - The caller is responsible for locking. - _check means that some checks are made. Signed-off-by: Manfred Spraul --- ipc/msg.c | 2 +- ipc/sem.c | 2 +- ipc/shm.c | 2 +- ipc/util.c | 6 +++--- ipc/util.h | 2 +- 5 files changed, 7 insert

[PATCH 2/6] ipc: reorganize initialization of kern_ipc_perm.seq

2018-07-05 Thread Manfred Spraul
not fullfill that, i.e. more bugfixes are required. Reported-by: syzbot+2827ef6b3385deb07...@syzkaller.appspotmail.com Signed-off-by: Manfred Spraul Cc: Dmitry Vyukov Cc: Kees Cook Cc: Davidlohr Bueso Cc: Michael Kerrisk Signed-off-by: Manfred Spraul --- Documentation/sysctl/kernel.txt | 3

[PATCH 6/6] ipc/util.c: correct comment in ipc_obtain_object_check

2018-07-05 Thread Manfred Spraul
=true may disappear at the end of the next rcu grace period. Signed-off-by: Manfred Spraul --- ipc/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ipc/util.c b/ipc/util.c index 4f2db913acf9..776a9ce2905f 100644 --- a/ipc/util.c +++ b/ipc/util.c @@ -646,8 +646,8

[PATCH 4/6] ipc: Rename ipcctl_pre_down_nolock().

2018-07-05 Thread Manfred Spraul
a pointer in the idr, without acquiring the object lock. - The caller is responsible for locking. - _check means that some checks are made. Signed-off-by: Manfred Spraul --- ipc/msg.c | 2 +- ipc/sem.c | 2 +- ipc/shm.c | 2 +- ipc/util.c | 6 +++--- ipc/util.h | 2 +- 5 files changed, 7 insert

[PATCH 5/6] ipc: rename ipc_lock() to ipc_lock_idr()

2018-07-05 Thread Manfred Spraul
that it does not check the sequence counter. Signed-off-by: Manfred Spraul --- ipc/shm.c | 4 ++-- ipc/util.c | 10 ++ ipc/util.h | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ipc/shm.c b/ipc/shm.c index 426ba1039a7b..cd8655c7bb77 100644 --- a/ipc/shm.c +++ b/ipc/shm.c

[PATCH 5/6] ipc: rename ipc_lock() to ipc_lock_idr()

2018-07-05 Thread Manfred Spraul
that it does not check the sequence counter. Signed-off-by: Manfred Spraul --- ipc/shm.c | 4 ++-- ipc/util.c | 10 ++ ipc/util.h | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ipc/shm.c b/ipc/shm.c index 426ba1039a7b..cd8655c7bb77 100644 --- a/ipc/shm.c +++ b/ipc/shm.c

[PATCH 1/6] ipc: reorganize initialization of kern_ipc_perm.id

2018-07-04 Thread Manfred Spraul
of syzbot+2827ef6b3385deb07...@syzkaller.appspotmail.com: syzbot found an issue with kern_ipc_perm.seq Signed-off-by: Manfred Spraul Cc: Dmitry Vyukov Cc: Kees Cook Cc: Davidlohr Bueso Signed-off-by: Manfred Spraul --- ipc/msg.c | 19 ++- ipc/sem.c | 18 +- ipc/shm.c

[PATCH 1/6] ipc: reorganize initialization of kern_ipc_perm.id

2018-07-04 Thread Manfred Spraul
of syzbot+2827ef6b3385deb07...@syzkaller.appspotmail.com: syzbot found an issue with kern_ipc_perm.seq Signed-off-by: Manfred Spraul Cc: Dmitry Vyukov Cc: Kees Cook Cc: Davidlohr Bueso Signed-off-by: Manfred Spraul --- ipc/msg.c | 19 ++- ipc/sem.c | 18 +- ipc/shm.c

[PATCH 0/5] ipc: cleanups & bugfixes

2018-07-04 Thread Manfred Spraul
ment-in-ipc_obtain_object_che Comment correction from code review The patches are lightly tested, especially I have not tested the checkpoint/restore code or tested the failure cases. -- Manfred

[PATCH 0/5] ipc: cleanups & bugfixes

2018-07-04 Thread Manfred Spraul
ment-in-ipc_obtain_object_che Comment correction from code review The patches are lightly tested, especially I have not tested the checkpoint/restore code or tested the failure cases. -- Manfred

Re: ipc/msg: zalloc struct msg_queue when creating a new msq

2018-07-04 Thread Manfred Spraul
Hello Dmitry, On 07/04/2018 12:03 PM, Dmitry Vyukov wrote: On Wed, Jul 4, 2018 at 11:18 AM, Manfred Spraul wrote: There are 2 relevant values: kern_ipc_perm.id and kern_ipc_perm.seq. For kern_ipc_perm.id, it is possible to move the access to the codepath that hold the lock

Re: ipc/msg: zalloc struct msg_queue when creating a new msq

2018-07-04 Thread Manfred Spraul
Hello Dmitry, On 07/04/2018 12:03 PM, Dmitry Vyukov wrote: On Wed, Jul 4, 2018 at 11:18 AM, Manfred Spraul wrote: There are 2 relevant values: kern_ipc_perm.id and kern_ipc_perm.seq. For kern_ipc_perm.id, it is possible to move the access to the codepath that hold the lock

[RFC] ipc: refcounting / use after free?

2018-07-04 Thread Manfred Spraul
The ipc code uses the equivalent of rcu_read_lock(); kfree_rcu(a, rcu); if (a->deleted) { rcu_read_unlock(); return FAILURE; } <...> Is this safe, or is dereferencing "a" after having called call_rcu() a use-after-free?

[RFC] ipc: refcounting / use after free?

2018-07-04 Thread Manfred Spraul
The ipc code uses the equivalent of rcu_read_lock(); kfree_rcu(a, rcu); if (a->deleted) { rcu_read_unlock(); return FAILURE; } <...> Is this safe, or is dereferencing "a" after having called call_rcu() a use-after-free?

Re: ipc/msg: zalloc struct msg_queue when creating a new msq

2018-07-04 Thread Manfred Spraul
the newly created object has temporarily sequence number 0 as well. --     Manfred >From 4791e604dcb618ed7ea1f42b2f6ca9cfe3c113c3 Mon Sep 17 00:00:00 2001 From: Manfred Spraul Date: Wed, 4 Jul 2018 10:04:49 +0200 Subject: [PATCH] ipc: fix races with kern_ipc_perm.id and .seq ipc_addid(

Re: ipc/msg: zalloc struct msg_queue when creating a new msq

2018-07-04 Thread Manfred Spraul
the newly created object has temporarily sequence number 0 as well. --     Manfred >From 4791e604dcb618ed7ea1f42b2f6ca9cfe3c113c3 Mon Sep 17 00:00:00 2001 From: Manfred Spraul Date: Wed, 4 Jul 2018 10:04:49 +0200 Subject: [PATCH] ipc: fix races with kern_ipc_perm.id and .seq ipc_addid(

Re: [REVIEW][PATCH 11/11] ipc/sem: Fix semctl(..., GETPID, ...) between pid namespaces

2018-04-02 Thread Manfred Spraul
re than ~8 processes on a 40 core box) in a non trivial way. For more processes it doesn't matter. We can confirm that the case for threads is irrelevant. While I'm not happy about the 30% regression I guess we can live with this. Manfred, any thoughts? Bugfixing has always first priority

Re: [REVIEW][PATCH 11/11] ipc/sem: Fix semctl(..., GETPID, ...) between pid namespaces

2018-04-02 Thread Manfred Spraul
re than ~8 processes on a 40 core box) in a non trivial way. For more processes it doesn't matter. We can confirm that the case for threads is irrelevant. While I'm not happy about the 30% regression I guess we can live with this. Manfred, any thoughts? Bugfixing has always first priority

Re: [RFC][PATCH] ipc: Remove IPCMNI

2018-03-29 Thread Manfred Spraul
Hello Mathew, On 03/29/2018 12:56 PM, Matthew Wilcox wrote: On Thu, Mar 29, 2018 at 10:47:45AM +0200, Manfred Spraul wrote: This can be implemented trivially with the current code using idr_alloc_cyclic. Is there a performance impact? Right now, the idr tree is only large if there are lots

Re: [RFC][PATCH] ipc: Remove IPCMNI

2018-03-29 Thread Manfred Spraul
Hello Mathew, On 03/29/2018 12:56 PM, Matthew Wilcox wrote: On Thu, Mar 29, 2018 at 10:47:45AM +0200, Manfred Spraul wrote: This can be implemented trivially with the current code using idr_alloc_cyclic. Is there a performance impact? Right now, the idr tree is only large if there are lots

Re: [RFC][PATCH] ipc: Remove IPCMNI

2018-03-29 Thread Manfred Spraul
Hello together, On 03/29/2018 04:14 AM, Davidlohr Bueso wrote: Cc'ing mtk, Manfred and linux-api. See below. On Thu, 15 Mar 2018, Waiman Long wrote: On 03/15/2018 03:00 PM, Eric W. Biederman wrote: Waiman Long <long...@redhat.com> writes: On 03/14/2018 08:49 PM, Eric W. Biederman

Re: [RFC][PATCH] ipc: Remove IPCMNI

2018-03-29 Thread Manfred Spraul
Hello together, On 03/29/2018 04:14 AM, Davidlohr Bueso wrote: Cc'ing mtk, Manfred and linux-api. See below. On Thu, 15 Mar 2018, Waiman Long wrote: On 03/15/2018 03:00 PM, Eric W. Biederman wrote: Waiman Long writes: On 03/14/2018 08:49 PM, Eric W. Biederman wrote: The define IPCMNI

[PATCH] mtd: nand: gpmi: fix edo mode for non fully ONFI compliant flashes

2018-02-20 Thread Manfred Schlaegl
rmance. To solve this, we simply remove the double-check, which is a paranoia check anyways. The modification was intensively tested on i.MX6 with linux-4.1, Winbond W29N04GV and Micron MT29F4G08ABADAH4. Signed-off-by: Manfred Schlaegl <manfred.schla...@ginzinger.com> --- drivers/mtd/nand/

[PATCH] mtd: nand: gpmi: fix edo mode for non fully ONFI compliant flashes

2018-02-20 Thread Manfred Schlaegl
rmance. To solve this, we simply remove the double-check, which is a paranoia check anyways. The modification was intensively tested on i.MX6 with linux-4.1, Winbond W29N04GV and Micron MT29F4G08ABADAH4. Signed-off-by: Manfred Schlaegl --- drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c | 9 + 1 f

Re: stable/linux-3.16.y build: 178 builds: 1 failed, 177 passed, 2 errors, 57 warnings (v3.16.52)

2018-01-13 Thread Manfred Spraul
D_ONCE(*p);   \ I don't see how ___p1 could be used uninitialized. Perhaps a compiler issue? --     Manfred

Re: stable/linux-3.16.y build: 178 builds: 1 failed, 177 passed, 2 errors, 57 warnings (v3.16.52)

2018-01-13 Thread Manfred Spraul
D_ONCE(*p);   \ I don't see how ___p1 could be used uninitialized. Perhaps a compiler issue? --     Manfred

Re: BUG: unable to handle kernel paging request in ipcget

2017-12-23 Thread Manfred Spraul
. Unfortunately, I don't have any reproducer for this bug yet. Is one of the recent issues reproducible? Either something is wrong with the faster ipc_get, or the improved ipc_get makes issues in other areas visible. --     Manfred

Re: BUG: unable to handle kernel paging request in ipcget

2017-12-23 Thread Manfred Spraul
. Unfortunately, I don't have any reproducer for this bug yet. Is one of the recent issues reproducible? Either something is wrong with the faster ipc_get, or the improved ipc_get makes issues in other areas visible. --     Manfred

Re: shmctl(SHM_STAT) vs. /proc/sysvipc/shm permissions discrepancies

2017-12-20 Thread Dr. Manfred Spraul
introduced. The changelog is really modest on information or intention but I suspect this just got overlooked during review. SHM_STAT has always been about read permission and it is explicitly documented that way. Are you sure that this patch changed the behavior? The proc interface is much older. --     Manfred

Re: shmctl(SHM_STAT) vs. /proc/sysvipc/shm permissions discrepancies

2017-12-20 Thread Dr. Manfred Spraul
introduced. The changelog is really modest on information or intention but I suspect this just got overlooked during review. SHM_STAT has always been about read permission and it is explicitly documented that way. Are you sure that this patch changed the behavior? The proc interface is much older. --     Manfred

Re: [PATCH 2/2] ipc: Fix ipc data structures inconsistency

2017-12-01 Thread Manfred Spraul
Hi, On 12/01/2017 06:20 PM, Davidlohr Bueso wrote: On Thu, 30 Nov 2017, Philippe Mikoyan wrote: As described in the title, this patch fixes id_ds inconsistency when ctl_stat runs concurrently with some ds-changing function, e.g. shmat, msgsnd or whatever. For instance, if shmctl(IPC_STAT) is

Re: [PATCH 2/2] ipc: Fix ipc data structures inconsistency

2017-12-01 Thread Manfred Spraul
Hi, On 12/01/2017 06:20 PM, Davidlohr Bueso wrote: On Thu, 30 Nov 2017, Philippe Mikoyan wrote: As described in the title, this patch fixes id_ds inconsistency when ctl_stat runs concurrently with some ds-changing function, e.g. shmat, msgsnd or whatever. For instance, if shmctl(IPC_STAT) is

Re: [PATCH v2 0/9] Remove spin_unlock_wait()

2017-07-10 Thread Manfred Spraul
wrote: * Manfred Spraul <manf...@colorfullife.com> wrote: Hi Ingo, On 07/07/2017 10:31 AM, Ingo Molnar wrote: There's another, probably just as significant advantage: queued_spin_unlock_wait() is 'read-only', while spin_lock()+spin_unlock() dirties the lock cache line. On any b

Re: [PATCH v2 0/9] Remove spin_unlock_wait()

2017-07-10 Thread Manfred Spraul
Hi Alan, On 07/08/2017 06:21 PM, Alan Stern wrote: Pardon me for barging in, but I found this whole interchange extremely confusing... On Sat, 8 Jul 2017, Ingo Molnar wrote: * Paul E. McKenney wrote: On Sat, Jul 08, 2017 at 10:35:43AM +0200, Ingo Molnar wrote: * Manfred Spraul wrote

Re: [PATCH v2 0/9] Remove spin_unlock_wait()

2017-07-07 Thread Manfred Spraul
()/spin_unlock(). -- Manfred

Re: [PATCH v2 0/9] Remove spin_unlock_wait()

2017-07-07 Thread Manfred Spraul
()/spin_unlock(). -- Manfred

Re: [PATCH v2 1/9] net/netfilter/nf_conntrack_core: Fix net_conntrack_lock()

2017-07-06 Thread Manfred Spraul
Hi Paul, On 07/06/2017 01:31 AM, Paul E. McKenney wrote: From: Manfred Spraul <manf...@colorfullife.com> As we want to remove spin_unlock_wait() and replace it with explicit spin_lock()/spin_unlock() calls, we can use this to simplify the locking. In addition: - Reading nf_conntrack_loc

Re: [PATCH v2 1/9] net/netfilter/nf_conntrack_core: Fix net_conntrack_lock()

2017-07-06 Thread Manfred Spraul
Hi Paul, On 07/06/2017 01:31 AM, Paul E. McKenney wrote: From: Manfred Spraul As we want to remove spin_unlock_wait() and replace it with explicit spin_lock()/spin_unlock() calls, we can use this to simplify the locking. In addition: - Reading nf_conntrack_locks_all needs ACQUIRE memory

Re: [PATCH RFC 01/26] netfilter: Replace spin_unlock_wait() with lock/unlock pair

2017-07-06 Thread Manfred Spraul
can test this? semop() has a very short hotpath. Either with aim9.shared_memory.ops_per_sec or #sem-scalebench -t 10 -m 0 https://github.com/manfred-colorfu/ipcscale/blob/master/sem-scalebench.cpp -- Manfred >From b549e0281b66124b62aa94543f91b0e616abaf52 Mon Sep 17 00:00:00 2001 From: Manf

Re: [PATCH RFC 01/26] netfilter: Replace spin_unlock_wait() with lock/unlock pair

2017-07-06 Thread Manfred Spraul
can test this? semop() has a very short hotpath. Either with aim9.shared_memory.ops_per_sec or #sem-scalebench -t 10 -m 0 https://github.com/manfred-colorfu/ipcscale/blob/master/sem-scalebench.cpp -- Manfred >From b549e0281b66124b62aa94543f91b0e616abaf52 Mon Sep 17 00:00:00 2001 From: Manf

Re: [PATCH RFC 01/26] netfilter: Replace spin_unlock_wait() with lock/unlock pair

2017-07-03 Thread Manfred Spraul
On 07/03/2017 07:14 PM, Paul E. McKenney wrote: On Mon, Jul 03, 2017 at 10:39:49AM -0400, Alan Stern wrote: On Sat, 1 Jul 2017, Manfred Spraul wrote: As we want to remove spin_unlock_wait() and replace it with explicit spin_lock()/spin_unlock() calls, we can use this to simplify the locking

Re: [PATCH RFC 01/26] netfilter: Replace spin_unlock_wait() with lock/unlock pair

2017-07-03 Thread Manfred Spraul
On 07/03/2017 07:14 PM, Paul E. McKenney wrote: On Mon, Jul 03, 2017 at 10:39:49AM -0400, Alan Stern wrote: On Sat, 1 Jul 2017, Manfred Spraul wrote: As we want to remove spin_unlock_wait() and replace it with explicit spin_lock()/spin_unlock() calls, we can use this to simplify the locking

Re: [PATCH RFC 06/26] ipc: Replace spin_unlock_wait() with lock/unlock pair

2017-07-01 Thread Manfred Spraul
immediately by spin_unlock(). This should be safe from a performance perspective because exit_sem() is rarely invoked in production. Signed-off-by: Paul E. McKenney <paul...@linux.vnet.ibm.com> Cc: Andrew Morton <a...@linux-foundation.org> Cc: Davidlohr Bueso <d...@stgolabs.net>

Re: [PATCH RFC 06/26] ipc: Replace spin_unlock_wait() with lock/unlock pair

2017-07-01 Thread Manfred Spraul
immediately by spin_unlock(). This should be safe from a performance perspective because exit_sem() is rarely invoked in production. Signed-off-by: Paul E. McKenney Cc: Andrew Morton Cc: Davidlohr Bueso Cc: Manfred Spraul Cc: Will Deacon Cc: Peter Zijlstra Cc: Alan Stern Cc: Andrea Parri

Re: [PATCH v2] refcount: Create unchecked atomic_t implementation

2017-06-08 Thread Manfred Spraul
for large arrays - alloc undo -- Manfred

Re: [PATCH v2] refcount: Create unchecked atomic_t implementation

2017-06-08 Thread Manfred Spraul
for large arrays - alloc undo -- Manfred

Re: [PATCH 1/3] ipc: convert ipc_namespace.count from atomic_t to refcount_t

2017-05-28 Thread Manfred Spraul
ounter overflows that might lead to use-after-free situations. Signed-off-by: Elena Reshetova <elena.reshet...@intel.com> Signed-off-by: Hans Liljestrand <ishkam...@gmail.com> Signed-off-by: Kees Cook <keesc...@chromium.org> Signed-off-by: David Windsor <dwind...@gmail.com> M

Re: [PATCH 1/3] ipc: convert ipc_namespace.count from atomic_t to refcount_t

2017-05-28 Thread Manfred Spraul
to use-after-free situations. Signed-off-by: Elena Reshetova Signed-off-by: Hans Liljestrand Signed-off-by: Kees Cook Signed-off-by: David Windsor Manfred, is this okay by you? I think this should go via -mm... The patch is ok, the refcounters are not in the critical path. I'll try to test

Re: [PATCH 0/20 V3] Misc cleanups for ipc

2017-05-25 Thread Manfred Spraul
Hi Kees, On 05/25/2017 09:45 PM, Kees Cook wrote: On Thu, May 25, 2017 at 11:50 AM, Manfred Spraul <manf...@colorfullife.com> wrote: Hi all, Updated series. The series got longer, because I merged all patches from Kees. Main changes are: - sems[] instead of sem[0]. - Immediate

Re: [PATCH 0/20 V3] Misc cleanups for ipc

2017-05-25 Thread Manfred Spraul
Hi Kees, On 05/25/2017 09:45 PM, Kees Cook wrote: On Thu, May 25, 2017 at 11:50 AM, Manfred Spraul wrote: Hi all, Updated series. The series got longer, because I merged all patches from Kees. Main changes are: - sems[] instead of sem[0]. - Immediately use BUILD_BUG_ON() - Immediately move

[PATCH 01/20] ipc/sem.c: remove sem_base, embed struct sem

2017-05-25 Thread Manfred Spraul
c code analysis. - This is a cast between different non-void types, which the future randstruct GCC plugin warns on. And, as bonus, the code size gets smaller: Before: 0 .text 3770 After: 0 .text 374e Signed-off-by: Manfred Spraul <manf...@colorfullife.com> --- i

[PATCH 01/20] ipc/sem.c: remove sem_base, embed struct sem

2017-05-25 Thread Manfred Spraul
c code analysis. - This is a cast between different non-void types, which the future randstruct GCC plugin warns on. And, as bonus, the code size gets smaller: Before: 0 .text 3770 After: 0 .text 374e Signed-off-by: Manfred Spraul --- include/linux/sem.

[PATCH 0/20 V3] Misc cleanups for ipc

2017-05-25 Thread Manfred Spraul
() was not successful @Andrew: Could you add them again to your tree? @Michael: Should we update man semctl(2)? Several years ago, I did a review and found that sem_ctime is only for Coherent the time of the last change... http://calculix-rpm.sourceforge.net/sysvsem.html -- Manfred

[PATCH 04/20] ipc: Drop non-RCU allocation

2017-05-25 Thread Manfred Spraul
Signed-off-by: Manfred Spraul <manf...@colorfullife.com> --- ipc/sem.c | 8 +--- ipc/util.c | 27 +++ ipc/util.h | 6 -- 3 files changed, 8 insertions(+), 33 deletions(-) diff --git a/ipc/sem.c b/ipc/sem.c index bdff6d9..484ccf8 100644 --- a/ipc/sem.c +++

[PATCH 04/20] ipc: Drop non-RCU allocation

2017-05-25 Thread Manfred Spraul
The only users of ipc_alloc() were ipc_rcu_alloc() and the on-heap sem_io fall-back memory. Better to just open-code these to make things easier to read. Signed-off-by: Kees Cook [manf...@colorfullife.com: Rediff due to inclusion of memset() into ipc_rcu_alloc().] Signed-off-by: Manfred Spraul

[PATCH 0/20 V3] Misc cleanups for ipc

2017-05-25 Thread Manfred Spraul
() was not successful @Andrew: Could you add them again to your tree? @Michael: Should we update man semctl(2)? Several years ago, I did a review and found that sem_ctime is only for Coherent the time of the last change... http://calculix-rpm.sourceforge.net/sysvsem.html -- Manfred

[PATCH 03/20] include/linux/sem.h: Correctly document sem_ctime

2017-05-25 Thread Manfred Spraul
that there is a comment in include/linux/sem.h and man semctl(2) as well. So: Correct wrong comments. Signed-off-by: Manfred Spraul <manf...@colorfullife.com> Cc: linux-...@vger.kernel.org --- include/linux/sem.h | 2 +- include/uapi/linux/sem.h | 2 +- 2 files changed, 2 insertions

[PATCH 03/20] include/linux/sem.h: Correctly document sem_ctime

2017-05-25 Thread Manfred Spraul
that there is a comment in include/linux/sem.h and man semctl(2) as well. So: Correct wrong comments. Signed-off-by: Manfred Spraul Cc: linux-...@vger.kernel.org --- include/linux/sem.h | 2 +- include/uapi/linux/sem.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git

[PATCH 06/20] ipc/shm: Do not use ipc_rcu_free()

2017-05-25 Thread Manfred Spraul
; Signed-off-by: Manfred Spraul <manf...@colorfullife.com> --- ipc/shm.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ipc/shm.c b/ipc/shm.c index 2eb85bd..77e1bff 100644 --- a/ipc/shm.c +++ b/ipc/shm.c @@ -172,6 +172,11 @@ static inline void shm_lock_by_ptr(s

[PATCH 06/20] ipc/shm: Do not use ipc_rcu_free()

2017-05-25 Thread Manfred Spraul
From: Kees Cook Avoid using ipc_rcu_free, since it just re-finds the original structure pointer. For the pre-list-init failure path, there is no RCU needed, since it was just allocated. It can be directly freed. Signed-off-by: Kees Cook Signed-off-by: Manfred Spraul --- ipc/shm.c | 9

[PATCH 07/20] ipc/msg: Do not use ipc_rcu_free()

2017-05-25 Thread Manfred Spraul
; Signed-off-by: Manfred Spraul <manf...@colorfullife.com> --- ipc/msg.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ipc/msg.c b/ipc/msg.c index 0ed7dae..25d43e2 100644 --- a/ipc/msg.c +++ b/ipc/msg.c @@ -95,13 +95,18 @@ static inline void msg_rmid(struct

[PATCH 07/20] ipc/msg: Do not use ipc_rcu_free()

2017-05-25 Thread Manfred Spraul
From: Kees Cook Avoid using ipc_rcu_free, since it just re-finds the original structure pointer. For the pre-list-init failure path, there is no RCU needed, since it was just allocated. It can be directly freed. Signed-off-by: Kees Cook Signed-off-by: Manfred Spraul --- ipc/msg.c | 9

[PATCH 08/20] ipc/util: Drop ipc_rcu_free()

2017-05-25 Thread Manfred Spraul
From: Kees Cook <keesc...@chromium.org> There are no more callers of ipc_rcu_free(), so remove it. Signed-off-by: Kees Cook <keesc...@chromium.org> Signed-off-by: Manfred Spraul <manf...@colorfullife.com> --- ipc/util.c | 7 --- ipc/util.h | 1 - 2 files changed, 8 deleti

[PATCH 08/20] ipc/util: Drop ipc_rcu_free()

2017-05-25 Thread Manfred Spraul
From: Kees Cook There are no more callers of ipc_rcu_free(), so remove it. Signed-off-by: Kees Cook Signed-off-by: Manfred Spraul --- ipc/util.c | 7 --- ipc/util.h | 1 - 2 files changed, 8 deletions(-) diff --git a/ipc/util.c b/ipc/util.c index dd73feb..556884b 100644 --- a/ipc/util.c

[PATCH 13/20] ipc/sem.c: Avoid ipc_rcu_putref for failed ipc_addid()

2017-05-25 Thread Manfred Spraul
ed-off-by: Manfred Spraul <manf...@colorfullife.com> Cc: Kees Cook <keesc...@chromium.org> --- ipc/sem.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ipc/sem.c b/ipc/sem.c index 445a5b5..2b2ed56 100644 --- a/ipc/sem.c +++ b/ipc/sem.c @@ -479,7 +479,

[PATCH 13/20] ipc/sem.c: Avoid ipc_rcu_putref for failed ipc_addid()

2017-05-25 Thread Manfred Spraul
Loosely based on a patch from Kees Cook : - id and retval can be merged - if ipc_addid() fails, then use call_rcu() directly. The difference is that call_rcu is used for failed ipc_addid() calls, to continue to guaranteed an rcu delay for security_sem_free(). Signed-off-by: Manfred Spraul Cc

[PATCH 14/20] ipc/shm.c: Avoid ipc_rcu_putref for failed ipc_addid()

2017-05-25 Thread Manfred Spraul
delay for security_sem_free(). Signed-off-by: Manfred Spraul <manf...@colorfullife.com> Cc: Kees Cook <keesc...@chromium.org> --- ipc/shm.c | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ipc/shm.c b/ipc/shm.c index c9f1f30..cb1d97e 100644 --- a/ipc/shm.c +++ b/i

[PATCH 14/20] ipc/shm.c: Avoid ipc_rcu_putref for failed ipc_addid()

2017-05-25 Thread Manfred Spraul
-off-by: Manfred Spraul Cc: Kees Cook --- ipc/shm.c | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ipc/shm.c b/ipc/shm.c index c9f1f30..cb1d97e 100644 --- a/ipc/shm.c +++ b/ipc/shm.c @@ -548,7 +548,6 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params

[PATCH 16/20] ipc: Move atomic_set() to where it is needed

2017-05-25 Thread Manfred Spraul
From: Kees Cook <keesc...@chromium.org> Only after ipc_addid() has succeeded will refcounting be used, so move initialization into ipc_addid() and remove from open-coded *_alloc() routines. Signed-off-by: Kees Cook <keesc...@chromium.org> Signed-off-by: Manfred Spraul <manf...@c

[PATCH 09/20] ipc/sem: Avoid ipc_rcu_alloc()

2017-05-25 Thread Manfred Spraul
omium.org> [manf...@colorfullife.com: Rediff, because the memset was temporarily inside ipc_rcu_alloc()] Signed-off-by: Manfred Spraul <manf...@colorfullife.com> --- ipc/sem.c | 25 - 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/ipc/sem.c b/ipc/s

[PATCH 16/20] ipc: Move atomic_set() to where it is needed

2017-05-25 Thread Manfred Spraul
From: Kees Cook Only after ipc_addid() has succeeded will refcounting be used, so move initialization into ipc_addid() and remove from open-coded *_alloc() routines. Signed-off-by: Kees Cook Signed-off-by: Manfred Spraul --- ipc/msg.c | 2 -- ipc/sem.c | 1 - ipc/shm.c | 2 -- ipc/util.c

[PATCH 09/20] ipc/sem: Avoid ipc_rcu_alloc()

2017-05-25 Thread Manfred Spraul
the memset was temporarily inside ipc_rcu_alloc()] Signed-off-by: Manfred Spraul --- ipc/sem.c | 25 - 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/ipc/sem.c b/ipc/sem.c index a04c4d6..445a5b5 100644 --- a/ipc/sem.c +++ b/ipc/sem.c @@ -451,6 +451,25 @@ static

[PATCH 12/20] ipc/util: Drop ipc_rcu_alloc()

2017-05-25 Thread Manfred Spraul
From: Kees Cook <keesc...@chromium.org> No callers remain for ipc_rcu_alloc(). Drop the function. Signed-off-by: Kees Cook <keesc...@chromium.org> [manf...@colorfullife.com: Rediff because the memset was temporarily inside ipc_rcu_free()] Signed-off-by: Manfred Spraul <manf...@c

[PATCH 12/20] ipc/util: Drop ipc_rcu_alloc()

2017-05-25 Thread Manfred Spraul
From: Kees Cook No callers remain for ipc_rcu_alloc(). Drop the function. Signed-off-by: Kees Cook [manf...@colorfullife.com: Rediff because the memset was temporarily inside ipc_rcu_free()] Signed-off-by: Manfred Spraul --- ipc/util.c | 21 - ipc/util.h | 3 --- 2

[PATCH 05/20] ipc/sem: Do not use ipc_rcu_free()

2017-05-25 Thread Manfred Spraul
; Signed-off-by: Manfred Spraul <manf...@colorfullife.com> --- ipc/sem.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ipc/sem.c b/ipc/sem.c index 484ccf8..a04c4d6 100644 --- a/ipc/sem.c +++ b/ipc/sem.c @@ -258,13 +258,18 @@ static void merge_queues(str

[PATCH 05/20] ipc/sem: Do not use ipc_rcu_free()

2017-05-25 Thread Manfred Spraul
From: Kees Cook Avoid using ipc_rcu_free, since it just re-finds the original structure pointer. For the pre-list-init failure path, there is no RCU needed, since it was just allocated. It can be directly freed. Signed-off-by: Kees Cook Signed-off-by: Manfred Spraul --- ipc/sem.c | 9

[PATCH 20/20] ipc/util.h: Update documentation for ipc_getref() and ipc_putref()

2017-05-25 Thread Manfred Spraul
Now that ipc_rcu_alloc() and ipc_rcu_free() are removed, document when it is valid to use ipc_getref() and ipc_putref(). Signed-off-by: Manfred Spraul <manf...@colorfullife.com> --- ipc/util.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ipc/util.h b/ipc/util.h index 77336c2b..c

[PATCH 18/20] ipc/msg: Remove special msg_alloc/free

2017-05-25 Thread Manfred Spraul
_queue_alloc()] Signed-off-by: Manfred Spraul <manf...@colorfullife.com> --- ipc/msg.c | 24 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/ipc/msg.c b/ipc/msg.c index 770342e..5b25e07 100644 --- a/ipc/msg.c +++ b/ipc/msg.c @@ -95,29 +95,13 @@ static inline vo

[PATCH 15/20] ipc/msg.c: Avoid ipc_rcu_putref for failed ipc_addid()

2017-05-25 Thread Manfred Spraul
Signed-off-by: Manfred Spraul <manf...@colorfullife.com> Cc: Kees Cook <keesc...@chromium.org> --- ipc/msg.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ipc/msg.c b/ipc/msg.c index 10094a7..cd90bfd 100644 --- a/ipc/msg.c +++ b/ipc/msg.c @@ -132,7 +132,

[PATCH 17/20] ipc/shm: Remove special shm_alloc/free

2017-05-25 Thread Manfred Spraul
a successful security_shm_alloc()] Signed-off-by: Manfred Spraul <manf...@colorfullife.com> --- ipc/shm.c | 24 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/ipc/shm.c b/ipc/shm.c index b85db5a..ec5688e 100644 --- a/ipc/shm.c +++ b/ipc/shm.c @@ -172,1

[PATCH 18/20] ipc/msg: Remove special msg_alloc/free

2017-05-25 Thread Manfred Spraul
From: Kees Cook There is nothing special about the msg_alloc/free routines any more, so remove them to make code more readable. Signed-off-by: Kees Cook [manf...@colorfullife.com: Rediff to keep rcu protection for security_msg_queue_alloc()] Signed-off-by: Manfred Spraul --- ipc/msg.c | 24

[PATCH 15/20] ipc/msg.c: Avoid ipc_rcu_putref for failed ipc_addid()

2017-05-25 Thread Manfred Spraul
Loosely based on a patch from Kees Cook : - id and retval can be merged - if ipc_addid() fails, then use call_rcu() directly. The difference is that call_rcu is used for failed ipc_addid() calls, to continue to guaranteed an rcu delay for security_msg_queue_free(). Signed-off-by: Manfred Spraul

[PATCH 17/20] ipc/shm: Remove special shm_alloc/free

2017-05-25 Thread Manfred Spraul
From: Kees Cook There is nothing special about the shm_alloc/free routines any more, so remove them to make code more readable. Signed-off-by: Kees Cook [manf...@colorfullife.com: Rediff, to continue to keep rcu for free calls after a successful security_shm_alloc()] Signed-off-by: Manfred

[PATCH 20/20] ipc/util.h: Update documentation for ipc_getref() and ipc_putref()

2017-05-25 Thread Manfred Spraul
Now that ipc_rcu_alloc() and ipc_rcu_free() are removed, document when it is valid to use ipc_getref() and ipc_putref(). Signed-off-by: Manfred Spraul --- ipc/util.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ipc/util.h b/ipc/util.h index 77336c2b..c692010 100644 --- a/ipc/util.h

<    1   2   3   4   5   6   7   8   9   10   >