Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=c895078355b6b6e05c60aa205892526dd3390f0a
Commit:     c895078355b6b6e05c60aa205892526dd3390f0a
Parent:     c2319540cd7330fa9066e5b9b84d357a2c8631a2
Author:     Oleg Nesterov <[EMAIL PROTECTED]>
AuthorDate: Wed Nov 28 16:21:24 2007 -0800
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Thu Nov 29 09:24:52 2007 -0800

    wait_task_stopped(): don't use task_pid_nr_ns() lockless
    
    wait_task_stopped(WNOWAIT) does task_pid_nr_ns() without tasklist/rcu lock,
    we can read an already freed memory.  Use the cached pid_t value.
    
    Signed-off-by: Oleg Nesterov <[EMAIL PROTECTED]>
    Looks-good-to: Roland McGrath <[EMAIL PROTECTED]>
    Acked-by: Pavel Emelyanov <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 kernel/exit.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/kernel/exit.c b/kernel/exit.c
index cd0f1d4..0a4a382 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -1357,7 +1357,7 @@ static int wait_task_stopped(struct task_struct *p, int 
delayed_group_leader,
                             int __user *stat_addr, struct rusage __user *ru)
 {
        int retval, exit_code;
-       struct pid_namespace *ns;
+       pid_t pid;
 
        if (!p->exit_code)
                return 0;
@@ -1376,12 +1376,11 @@ static int wait_task_stopped(struct task_struct *p, int 
delayed_group_leader,
         * keep holding onto the tasklist_lock while we call getrusage and
         * possibly take page faults for user memory.
         */
-       ns = current->nsproxy->pid_ns;
+       pid = task_pid_nr_ns(p, current->nsproxy->pid_ns);
        get_task_struct(p);
        read_unlock(&tasklist_lock);
 
        if (unlikely(noreap)) {
-               pid_t pid = task_pid_nr_ns(p, ns);
                uid_t uid = p->uid;
                int why = (p->ptrace & PT_PTRACED) ? CLD_TRAPPED : CLD_STOPPED;
 
@@ -1451,11 +1450,11 @@ bail_ref:
        if (!retval && infop)
                retval = put_user(exit_code, &infop->si_status);
        if (!retval && infop)
-               retval = put_user(task_pid_nr_ns(p, ns), &infop->si_pid);
+               retval = put_user(pid, &infop->si_pid);
        if (!retval && infop)
                retval = put_user(p->uid, &infop->si_uid);
        if (!retval)
-               retval = task_pid_nr_ns(p, ns);
+               retval = pid;
        put_task_struct(p);
 
        BUG_ON(!retval);
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to