mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
block: fix ioprio_get(IOPRIO_WHO_PGRP) vs setuid(2)
commite6a59aac8aupstream. 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:d69b78ba1d(ioprio: grab rcu_read_lock in sys_ioprio_{set,get}()) Acked-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Davidlohr Bueso <dbueso@suse.de> Link: https://lore.kernel.org/r/20211210182058.43417-1-dave@stgolabs.net Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
5f1f94c26b
commit
5dfe611474
@@ -214,6 +214,7 @@ SYSCALL_DEFINE2(ioprio_get, int, which, int, who)
|
|||||||
pgrp = task_pgrp(current);
|
pgrp = task_pgrp(current);
|
||||||
else
|
else
|
||||||
pgrp = find_vpid(who);
|
pgrp = find_vpid(who);
|
||||||
|
read_lock(&tasklist_lock);
|
||||||
do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
|
do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
|
||||||
tmpio = get_task_ioprio(p);
|
tmpio = get_task_ioprio(p);
|
||||||
if (tmpio < 0)
|
if (tmpio < 0)
|
||||||
@@ -223,6 +224,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which, int, who)
|
|||||||
else
|
else
|
||||||
ret = ioprio_best(ret, tmpio);
|
ret = ioprio_best(ret, tmpio);
|
||||||
} while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
|
} while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
|
||||||
|
read_unlock(&tasklist_lock);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case IOPRIO_WHO_USER:
|
case IOPRIO_WHO_USER:
|
||||||
uid = make_kuid(current_user_ns(), who);
|
uid = make_kuid(current_user_ns(), who);
|
||||||
|
|||||||
Reference in New Issue
Block a user