The patch titled pids: improve get_task_pid() to fix the unsafe sys_wait4()->task_pgrp() has been added to the -mm tree. Its filename is pids-improve-get_task_pid-to-fix-the-unsafe-sys_wait4-task_pgrp.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find out what to do about this The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ Subject: pids: improve get_task_pid() to fix the unsafe sys_wait4()->task_pgrp() From: Oleg Nesterov <oleg@xxxxxxxxxx> 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@xxxxxxxxxx> Cc: Louis Rilling <Louis.Rilling@xxxxxxxxxxx> Cc: "Eric W. Biederman" <ebiederm@xxxxxxxxxxxx> Cc: Pavel Emelyanov <xemul@xxxxxxxxxx> Cc: Sukadev Bhattiprolu <sukadev@xxxxxxxxxxxxxxxxxx> Cc: Roland McGrath <roland@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- kernel/exit.c | 2 +- kernel/pid.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff -puN kernel/exit.c~pids-improve-get_task_pid-to-fix-the-unsafe-sys_wait4-task_pgrp kernel/exit.c --- a/kernel/exit.c~pids-improve-get_task_pid-to-fix-the-unsafe-sys_wait4-task_pgrp +++ a/kernel/exit.c @@ -1819,7 +1819,7 @@ SYSCALL_DEFINE4(wait4, pid_t, upid, int 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); diff -puN kernel/pid.c~pids-improve-get_task_pid-to-fix-the-unsafe-sys_wait4-task_pgrp kernel/pid.c --- a/kernel/pid.c~pids-improve-get_task_pid-to-fix-the-unsafe-sys_wait4-task_pgrp +++ a/kernel/pid.c @@ -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; _ Patches currently in -mm which might be from oleg@xxxxxxxxxx are getrusage-fill-ru_maxrss-value.patch pids-document-task_pgrp-task_session-is-not-safe-without-tasklist-rcu.patch pids-document-task_pgrp-task_session-is-not-safe-without-tasklist-rcu-fix.patch pids-improve-get_task_pid-to-fix-the-unsafe-sys_wait4-task_pgrp.patch pids-refactor-vnr-nr_ns-helpers-to-make-them-safe.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html