Skip to content

Commit

Permalink
proc: prevent changes to overridden credentials
Browse files Browse the repository at this point in the history
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: <[email protected]>
Reported-by: "chengjian (D)" <[email protected]>
Signed-off-by: Paul Moore <[email protected]>
Acked-by: John Johansen <[email protected]>
Acked-by: James Morris <[email protected]>
Acked-by: Casey Schaufler <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
pcmoore authored and gregkh committed May 25, 2019
1 parent bbd559a commit 7928396
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fs/proc/base.c
Original file line number Diff line number Diff line change
@@ -2542,6 +2542,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)

0 comments on commit 7928396

Please sign in to comment.