]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - kernel/ptrace.c
CRED: Inaugurate COW credentials
[net-next-2.6.git] / kernel / ptrace.c
index b9d5f4e4f6a4ed1c297b24474f779a8228fb78c8..f764b88069555856cf265e7354ca1f10a38e95d3 100644 (file)
@@ -171,6 +171,14 @@ int ptrace_attach(struct task_struct *task)
        if (same_thread_group(task, current))
                goto out;
 
+       /* Protect exec's credential calculations against our interference;
+        * SUID, SGID and LSM creds get determined differently under ptrace.
+        */
+       retval = mutex_lock_interruptible(&current->cred_exec_mutex);
+       if (retval  < 0)
+               goto out;
+
+       retval = -EPERM;
 repeat:
        /*
         * Nasty, nasty.
@@ -210,6 +218,7 @@ repeat:
 bad:
        write_unlock_irqrestore(&tasklist_lock, flags);
        task_unlock(task);
+       mutex_unlock(&current->cred_exec_mutex);
 out:
        return retval;
 }