]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
proc: prevent changes to overridden credentials
authorPaul Moore <paul@paul-moore.com>
Fri, 19 Apr 2019 18:55:12 +0000 (14:55 -0400)
committerPaul Moore <paul@paul-moore.com>
Mon, 29 Apr 2019 13:51:21 +0000 (09:51 -0400)
Prevent userspace from changing the the /proc/PID/attr values if the
task's credentials are currently overriden.  This not only makes sense
conceptually, it also prevents some really bizarre error cases caused
when trying to commit credentials to a task with overridden
credentials.

Cc: <stable@vger.kernel.org>
Reported-by: "chengjian (D)" <cj.chengjian@huawei.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Acked-by: John Johansen <john.johansen@canonical.com>
Acked-by: James Morris <james.morris@microsoft.com>
Acked-by: Casey Schaufler <casey@schaufler-ca.com>
fs/proc/base.c

index ddef482f133406737e09e5df4966aea9b6ec06aa..87ba007b86dbb1821b387e2ecaf54ab9bc6e7f0f 100644 (file)
@@ -2539,6 +2539,11 @@ static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf,
                rcu_read_unlock();
                return -EACCES;
        }
+       /* Prevent changes to overridden credentials. */
+       if (current_cred() != current_real_cred()) {
+               rcu_read_unlock();
+               return -EBUSY;
+       }
        rcu_read_unlock();
 
        if (count > PAGE_SIZE)