]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 25 May 2019 16:22:01 +0000 (18:22 +0200)
commit 35a196bef449b5824033865b963ed9a43fb8c730 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/proc/base.c

index f5ed9512d193a2d93df6fc54cd2202ad3367fb41..ef11c54ad7125fc9214dba01c10bb775c562a60a 100644 (file)
@@ -2550,6 +2550,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)