Skip to content

Commit 35a196b

Browse files
committed
proc: prevent changes to overridden credentials
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]>
1 parent c750e69 commit 35a196b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

fs/proc/base.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2539,6 +2539,11 @@ static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf,
25392539
rcu_read_unlock();
25402540
return -EACCES;
25412541
}
2542+
/* Prevent changes to overridden credentials. */
2543+
if (current_cred() != current_real_cred()) {
2544+
rcu_read_unlock();
2545+
return -EBUSY;
2546+
}
25422547
rcu_read_unlock();
25432548

25442549
if (count > PAGE_SIZE)

0 commit comments

Comments
 (0)