All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/3] pids: immprove get_task_pid() to fix the unsafe sys_wait4()->task_pgrp()
@ 2009-01-16  5:55 Oleg Nesterov
  0 siblings, 0 replies; only message in thread
From: Oleg Nesterov @ 2009-01-16  5:55 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Eric W. Biederman, Pavel Emelyanov, Sukadev Bhattiprolu,
	linux-kernel

sys_wait4() does get_pid(task_pgrp(current)), this is not safe. We can
add rcu lock/unlock around, but we already have get_task_pid() which can
be improved to handle the special pids in more reliable manner.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>

--- CUR/kernel/pid.c~SP_2_wait	2009-01-12 23:07:49.000000000 +0100
+++ CUR/kernel/pid.c	2009-01-16 02:54:26.000000000 +0100
@@ -403,6 +403,8 @@ struct pid *get_task_pid(struct task_str
 {
 	struct pid *pid;
 	rcu_read_lock();
+	if (type != PIDTYPE_PID)
+		task = task->group_leader;
 	pid = get_pid(task->pids[type].pid);
 	rcu_read_unlock();
 	return pid;
--- CUR/kernel/exit.c~SP_2_wait	2009-01-12 23:07:49.000000000 +0100
+++ CUR/kernel/exit.c	2009-01-16 02:51:48.000000000 +0100
@@ -1811,7 +1811,7 @@ asmlinkage long sys_wait4(pid_t upid, in
 		pid = find_get_pid(-upid);
 	} else if (upid == 0) {
 		type = PIDTYPE_PGID;
-		pid = get_pid(task_pgrp(current));
+		pid = get_task_pid(current, PIDTYPE_PGID);
 	} else /* upid > 0 */ {
 		type = PIDTYPE_PID;
 		pid = find_get_pid(upid);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-01-16  5:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-16  5:55 [PATCH 2/3] pids: immprove get_task_pid() to fix the unsafe sys_wait4()->task_pgrp() Oleg Nesterov

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.