Merge branch 'akpm' (Andrew's patch-bomb)
[~shefty/rdma-dev.git] / kernel / ptrace.c
index ec8118ab2a47edaacda635a5eca0a104db3c09b3..1599157336a6c2be56037a510b7c2c28648201b8 100644 (file)
@@ -215,8 +215,12 @@ ok:
        smp_rmb();
        if (task->mm)
                dumpable = get_dumpable(task->mm);
-       if (!dumpable  && !ptrace_has_cap(task_user_ns(task), mode))
+       rcu_read_lock();
+       if (!dumpable && !ptrace_has_cap(__task_cred(task)->user_ns, mode)) {
+               rcu_read_unlock();
                return -EPERM;
+       }
+       rcu_read_unlock();
 
        return security_ptrace_access_check(task, mode);
 }
@@ -280,8 +284,10 @@ static int ptrace_attach(struct task_struct *task, long request,
 
        if (seize)
                flags |= PT_SEIZED;
-       if (ns_capable(task_user_ns(task), CAP_SYS_PTRACE))
+       rcu_read_lock();
+       if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
                flags |= PT_PTRACE_CAP;
+       rcu_read_unlock();
        task->ptrace = flags;
 
        __ptrace_link(task, current);