All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] block: Use for_each_thread() in sys_ioprio_set()/sys_ioprio_get()
@ 2017-02-02 13:22 Tetsuo Handa
  2017-02-02 13:22 ` [PATCH 2/2] pid: Use for_each_thread() in do_each_pid_thread() Tetsuo Handa
  0 siblings, 1 reply; 2+ messages in thread
From: Tetsuo Handa @ 2017-02-02 13:22 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, Tetsuo Handa, Oleg Nesterov

IOPRIO_WHO_USER case in sys_ioprio_set()/sys_ioprio_get() are using
while_each_thread(), which is unsafe under RCU lock according to
commit 0c740d0afc3bff0a ("introduce for_each_thread() to replace
the buggy while_each_thread()"). Use for_each_thread() which is
safe under RCU lock.

Link: http://lkml.kernel.org/r/201702011947.DBD56740.OMVHOLOtSJFFFQ@I-love.SAKURA.ne.jp
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Oleg Nesterov <oleg@redhat.com>
---
 block/ioprio.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/block/ioprio.c b/block/ioprio.c
index 01b8116..3790669 100644
--- a/block/ioprio.c
+++ b/block/ioprio.c
@@ -122,14 +122,14 @@ int set_task_ioprio(struct task_struct *task, int ioprio)
 			if (!user)
 				break;
 
-			do_each_thread(g, p) {
+			for_each_process_thread(g, p) {
 				if (!uid_eq(task_uid(p), uid) ||
 				    !task_pid_vnr(p))
 					continue;
 				ret = set_task_ioprio(p, ioprio);
 				if (ret)
 					goto free_uid;
-			} while_each_thread(g, p);
+			}
 free_uid:
 			if (who)
 				free_uid(user);
@@ -222,7 +222,7 @@ int ioprio_best(unsigned short aprio, unsigned short bprio)
 			if (!user)
 				break;
 
-			do_each_thread(g, p) {
+			for_each_process_thread(g, p) {
 				if (!uid_eq(task_uid(p), user->uid) ||
 				    !task_pid_vnr(p))
 					continue;
@@ -233,7 +233,7 @@ int ioprio_best(unsigned short aprio, unsigned short bprio)
 					ret = tmpio;
 				else
 					ret = ioprio_best(ret, tmpio);
-			} while_each_thread(g, p);
+			}
 
 			if (who)
 				free_uid(user);
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 2/2] pid: Use for_each_thread() in do_each_pid_thread()
  2017-02-02 13:22 [PATCH 1/2] block: Use for_each_thread() in sys_ioprio_set()/sys_ioprio_get() Tetsuo Handa
@ 2017-02-02 13:22 ` Tetsuo Handa
  0 siblings, 0 replies; 2+ messages in thread
From: Tetsuo Handa @ 2017-02-02 13:22 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, Tetsuo Handa, Oleg Nesterov

while_each_pid_thread() is using while_each_thread(), which is unsafe
under RCU lock according to commit 0c740d0afc3bff0a ("introduce
for_each_thread() to replace the buggy while_each_thread()"). Use
for_each_thread() in do_each_pid_thread() which is safe under RCU lock.

Link: http://lkml.kernel.org/r/201702011947.DBD56740.OMVHOLOtSJFFFQ@I-love.SAKURA.ne.jp
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Oleg Nesterov <oleg@redhat.com>
---
 include/linux/pid.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/pid.h b/include/linux/pid.h
index 23705a5..298ead55 100644
--- a/include/linux/pid.h
+++ b/include/linux/pid.h
@@ -191,10 +191,10 @@ static inline pid_t pid_nr(struct pid *pid)
 #define do_each_pid_thread(pid, type, task)				\
 	do_each_pid_task(pid, type, task) {				\
 		struct task_struct *tg___ = task;			\
-		do {
+		for_each_thread(tg___, task) {
 
 #define while_each_pid_thread(pid, type, task)				\
-		} while_each_thread(tg___, task);			\
+		}							\
 		task = tg___;						\
 	} while_each_pid_task(pid, type, task)
 #endif /* _LINUX_PID_H */
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-02-02 13:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-02 13:22 [PATCH 1/2] block: Use for_each_thread() in sys_ioprio_set()/sys_ioprio_get() Tetsuo Handa
2017-02-02 13:22 ` [PATCH 2/2] pid: Use for_each_thread() in do_each_pid_thread() Tetsuo Handa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.