Skip to content

Commit e6a59aa

Browse files
Davidlohr Buesoaxboe
authored andcommitted
block: fix ioprio_get(IOPRIO_WHO_PGRP) vs setuid(2)
do_each_pid_thread(PIDTYPE_PGID) can race with a concurrent change_pid(PIDTYPE_PGID) that can move the task from one hlist to another while iterating. Serialize ioprio_get to take the tasklist_lock in this case, just like it's set counterpart. Fixes: d69b78b (ioprio: grab rcu_read_lock in sys_ioprio_{set,get}()) Acked-by: Oleg Nesterov <[email protected]> Signed-off-by: Davidlohr Bueso <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent a5c2455 commit e6a59aa

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

block/ioprio.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ SYSCALL_DEFINE2(ioprio_get, int, which, int, who)
220220
pgrp = task_pgrp(current);
221221
else
222222
pgrp = find_vpid(who);
223+
read_lock(&tasklist_lock);
223224
do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
224225
tmpio = get_task_ioprio(p);
225226
if (tmpio < 0)
@@ -229,6 +230,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which, int, who)
229230
else
230231
ret = ioprio_best(ret, tmpio);
231232
} while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
233+
read_unlock(&tasklist_lock);
234+
232235
break;
233236
case IOPRIO_WHO_USER:
234237
uid = make_kuid(current_user_ns(), who);

0 commit comments

Comments
 (0)