aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Gordon <[email protected]>2019-01-03 15:25:56 -0800
committerLinus Torvalds <[email protected]>2019-01-04 13:13:45 -0800
commit8da0b4f692c6d90b09c91f271517db746a22ff67 (patch)
tree534a079733c187dda524c8f248d1bcbecbf83dc6
parent645ff1e8e704c4f33ab1fcd3c87f95cb9b6d7144 (diff)
fs/proc/base.c: use ns_capable instead of capable for timerslack_ns
Access to timerslack_ns is controlled by a process having CAP_SYS_NICE in its effective capability set, but the current check looks in the root namespace instead of the process' user namespace. Since a process is allowed to do other activities controlled by CAP_SYS_NICE inside a namespace, it should also be able to adjust timerslack_ns. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Benjamin Gordon <[email protected]> Acked-by: "Eric W. Biederman" <[email protected]> Cc: John Stultz <[email protected]> Cc: "Eric W. Biederman" <[email protected]> Cc: Kees Cook <[email protected]> Cc: "Serge E. Hallyn" <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Arjan van de Ven <[email protected]> Cc: Oren Laadan <[email protected]> Cc: Ruchi Kandoi <[email protected]> Cc: Rom Lemarchand <[email protected]> Cc: Todd Kjos <[email protected]> Cc: Colin Cross <[email protected]> Cc: Nick Kralevich <[email protected]> Cc: Dmitry Shmidt <[email protected]> Cc: Elliott Hughes <[email protected]> Cc: Alexey Dobriyan <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r--fs/proc/base.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c
index d7fd1ca807d2..58a8dc3fd6c6 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -2356,10 +2356,13 @@ static ssize_t timerslack_ns_write(struct file *file, const char __user *buf,
return -ESRCH;
if (p != current) {
- if (!capable(CAP_SYS_NICE)) {
+ rcu_read_lock();
+ if (!ns_capable(__task_cred(p)->user_ns, CAP_SYS_NICE)) {
+ rcu_read_unlock();
count = -EPERM;
goto out;
}
+ rcu_read_unlock();
err = security_task_setscheduler(p);
if (err) {
@@ -2392,11 +2395,14 @@ static int timerslack_ns_show(struct seq_file *m, void *v)
return -ESRCH;
if (p != current) {
-
- if (!capable(CAP_SYS_NICE)) {
+ rcu_read_lock();
+ if (!ns_capable(__task_cred(p)->user_ns, CAP_SYS_NICE)) {
+ rcu_read_unlock();
err = -EPERM;
goto out;
}
+ rcu_read_unlock();
+
err = security_task_getscheduler(p);
if (err)
goto out;