ioprio: rcu_read_lock/unlock protect find_task_by_vpid call (V2)
PATCH 1/1 ioprio: rcu_read_lock/unlock protect find_task_by_vpid call (V2)
Commit 4221a9918e38b7494cee341dda7b7b4bb8c04bde "Add RCU check for find_task_by_vpid()" introduced rcu_lockdep_assert to find_task_by_pid_ns. Assertion failed in sys_ioprio_get. The patch is fixing assertion failure in ioprio_set as well.
kernel/pid.c:419 invoked rcu_dereference_check() without protection!
stack backtrace: Pid: 4254, comm: iotop Not tainted Call Trace: [<ffffffff810656f2>] lockdep_rcu_dereference+0xaa/0xb2 [<ffffffff81053c67>] find_task_by_pid_ns+0x4f/0x68 [<ffffffff81053c9d>] find_task_by_vpid+0x1d/0x1f [<ffffffff811104e2>] sys_ioprio_get+0x50/0x2da [<ffffffff81002182>] system_call_fastpath+0x16/0x1b
V2: rcu critical section expanded according to comment by Paul E. McKenne:
| Looking over the patch again, the scope of the RCU read-side critical | section needs to expand to cover the use of the pointer as well as the | call to find_task_by_vpid().
---
fs/ioprio.c +4 -0
@@ -111,12 +111,14 @@ SYSCALL_DEFINE3(ioprio_set, int, which, int, who, int, ioprio)read_lock (&tasklist_lock);switch (which) {case IOPRIO_WHO_PROCESS : +rcu_read_lock ();if (!who) p = current;else p =find_task_by_vpid (who);if (p) ret =set_task_ioprio (p, ioprio); +rcu_read_unlock ();break ;case IOPRIO_WHO_PGRP :if (!who)
@@ -200,12 +202,14 @@ SYSCALL_DEFINE2(ioprio_get, int, which, int, who)read_lock (&tasklist_lock);switch (which) {case IOPRIO_WHO_PROCESS : +rcu_read_lock ();if (!who) p = current;else p =find_task_by_vpid (who);if (p) ret =get_task_ioprio (p); +rcu_read_unlock ();break ;case IOPRIO_WHO_PGRP :if (!who)
Quoted 16 lines · Sergey Senozhatsky
Commit
4221a9918e38b7494cee341dda7b7b4bb8c04bde"Add RCU check forfind_task_by_vpid()" introducedrcu_lockdep_asserttofind_task_by_pid_ns. Assertion failed insys_ioprio_get. The patch is fixing assertion failure inioprio_setas well.
kernel/pid.c:419invokedrcu_dereference_check()without protection!stack backtrace: Pid: 4254, comm: iotop Not tainted Call Trace: [<ffffffff810656f2>] lockdep_rcu_dereference+0xaa/0xb2 [<ffffffff81053c67>] find_task_by_pid_ns+0x4f/0x68 [<ffffffff81053c9d>] find_task_by_vpid+0x1d/0x1f [<ffffffff811104e2>] sys_ioprio_get+0x50/0x2da [<ffffffff81002182>] system_call_fastpath+0x16/0x1b
Quoted 4 lines
V2: rcu critical section expanded according to comment by Paul E. McKenne:
| Looking over the patch again, the scope of the RCU read-side critical | section needs to expand to cover the use of the pointer as well as the | call to find_task_by_vpid().
Thank you, Sergey!
Jens, are you willing to take this one?
Thanx, Paul
Quoted 39 lines
Signed-off-by Sergey Senozhatsky <[email protected]>---
fs/ioprio.c +4
-0@@ -111,12 +111,14 @@ SYSCALL_DEFINE3(ioprio_set, int, which, int, who, int, ioprio)read_lock (&tasklist_lock);switch (which) {case IOPRIO_WHO_PROCESS : +rcu_read_lock ();if (!who) p = current;else p =find_task_by_vpid (who);if (p) ret =set_task_ioprio (p, ioprio); +rcu_read_unlock ();break ;case IOPRIO_WHO_PGRP :if (!who)@@ -200,12 +202,14 @@ SYSCALL_DEFINE2(ioprio_get, int, which, int, who)read_lock (&tasklist_lock);switch (which) {case IOPRIO_WHO_PROCESS : +rcu_read_lock ();if (!who) p = current;else p =find_task_by_vpid (who);if (p) ret =get_task_ioprio (p); +rcu_read_unlock ();break ;case IOPRIO_WHO_PGRP :if (!who)
Quoted 22 lines · Paul E. McKenney
Quoted 16 lines · Sergey Senozhatsky
Commit
4221a9918e38b7494cee341dda7b7b4bb8c04bde"Add RCU check forfind_task_by_vpid()" introducedrcu_lockdep_asserttofind_task_by_pid_ns.. Assertion failed insys_ioprio_get. The patch is fixing assertion failure inioprio_setas well.
kernel/pid.c:419invokedrcu_dereference_check()without protection!stack backtrace: Pid: 4254, comm: iotop Not tainted Call Trace: [<ffffffff810656f2>] lockdep_rcu_dereference+0xaa/0xb2 [<ffffffff81053c67>] find_task_by_pid_ns+0x4f/0x68 [<ffffffff81053c9d>] find_task_by_vpid+0x1d/0x1f [<ffffffff811104e2>] sys_ioprio_get+0x50/0x2da [<ffffffff81002182>] system_call_fastpath+0x16/0x1bQuoted 4 lines
V2: rcu critical section expanded according to comment by Paul E. McKenne:
| Looking over the patch again, the scope of the RCU read-side critical | section needs to expand to cover the use of the pointer as well as the | call to find_task_by_vpid().
Quoted 5 lines
Thank you, Sergey!
Acked-by Paul E. McKenney <[email protected]>Jens, are you willing to take this one?
Certainly, thanks guys!
Signature · 1 line
Jens Axboe
Quoted 8 lines · Jens Axboe
Quoted 5 lines
Thank you, Sergey!
Acked-by Paul E. McKenney <[email protected]>Jens, are you willing to take this one?
Certainly, thanks guys!
Thank you,
Sergey