Re: [PATCH 0/3] exec: Transform exec_update_mutex into a rw_semaphore

2020-12-03 Thread Davidlohr Bueso

On Thu, 03 Dec 2020, Linus Torvalds wrote:


On Thu, Dec 3, 2020 at 12:10 PM Eric W. Biederman  wrote:


The simplest and most robust solution appears to be making
exec_update_mutex a read/write lock and having everything execept for
exec take the lock for read.


Looks sane to me.

I'd like the locking people to look at the down_read_*() functions,
even if they look simple. Adding Waiman and Davidlohr to the cc just
in case they would look at that too, since they've worked on that
code.


rwsem changes look good to me - and 3/3 looks much nicer than the previous
alternatives to the deadlock.

Acked-by: Davidlohr Bueso 


Re: [PATCH 0/3] exec: Transform exec_update_mutex into a rw_semaphore

2020-12-03 Thread Waiman Long

On 12/3/20 5:42 PM, Linus Torvalds wrote:

On Thu, Dec 3, 2020 at 12:10 PM Eric W. Biederman  wrote:

The simplest and most robust solution appears to be making
exec_update_mutex a read/write lock and having everything execept for
exec take the lock for read.

Looks sane to me.

I'd like the locking people to look at the down_read_*() functions,
even if they look simple. Adding Waiman and Davidlohr to the cc just
in case they would look at that too, since they've worked on that
code.


I have looked at patches 1 & 2 on adding down_read_killable_nested() and 
down_read_interruptible(). They looks good to me.


Cheers,
Longman



Re: [PATCH 0/3] exec: Transform exec_update_mutex into a rw_semaphore

2020-12-03 Thread Linus Torvalds
On Thu, Dec 3, 2020 at 12:10 PM Eric W. Biederman  wrote:
>
> The simplest and most robust solution appears to be making
> exec_update_mutex a read/write lock and having everything execept for
> exec take the lock for read.

Looks sane to me.

I'd like the locking people to look at the down_read_*() functions,
even if they look simple. Adding Waiman and Davidlohr to the cc just
in case they would look at that too, since they've worked on that
code.

Linus


[PATCH 0/3] exec: Transform exec_update_mutex into a rw_semaphore

2020-12-03 Thread Eric W. Biederman


Recently syzbot reported[0] that there is a deadlock amongst the users
of exec_update_mutex.

The simplest and most robust solution appears to be making
exec_update_mutex a read/write lock and having everything execept for
exec take the lock for read.

This set of changes upgrades rwsem so it has the functionality needed
and uses a rw_semaphore to replace the current mutex.

Eric W. Biederman (3):
  rwsem: Implement down_read_killable_nested
  rwsem: Implement down_read_interruptible
  exec: Transform exec_update_mutex into a rw_semaphore

 fs/exec.c| 12 ++--
 fs/proc/base.c   | 10 +-
 include/linux/rwsem.h|  3 +++
 include/linux/sched/signal.h | 11 ++-
 init/init_task.c |  2 +-
 kernel/events/core.c | 12 ++--
 kernel/fork.c|  6 +++---
 kernel/kcmp.c| 30 +++---
 kernel/locking/rwsem.c   | 40 
 kernel/pid.c |  4 ++--
 10 files changed, 87 insertions(+), 43 deletions(-)

[0] https://lkml.kernel.org/r/63640c05ade8e...@google.com

Eric