On Wed, Oct 17, 2018 at 3:47 PM, <bmgor...@google.com> wrote: > From: Benjamin Gordon <bmgor...@google.com> > > 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. > > Signed-off-by: Benjamin Gordon <bmgor...@google.com> > Cc: John Stultz <john.stu...@linaro.org> > Cc: Kees Cook <keesc...@chromium.org> > Cc: "Serge E. Hallyn" <se...@hallyn.com> > Cc: Thomas Gleixner <t...@linutronix.de> > Cc: Arjan van de Ven <ar...@linux.intel.com> > Cc: Oren Laadan <or...@cellrox.com> > Cc: Ruchi Kandoi <kandoiru...@google.com> > Cc: Rom Lemarchand <rom...@android.com> > Cc: Todd Kjos <tk...@google.com> > Cc: Colin Cross <ccr...@android.com> > Cc: Nick Kralevich <n...@google.com> > Cc: Dmitry Shmidt <dimitr...@google.com> > Cc: Elliott Hughes <e...@google.com> > Cc: Android Kernel Team <kernel-t...@android.com> > Cc: Andrew Morton <a...@linux-foundation.org> > --- > fs/proc/base.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/fs/proc/base.c b/fs/proc/base.c > index 7e9f07bf260d..4b50937dff80 100644 > --- a/fs/proc/base.c > +++ b/fs/proc/base.c > @@ -2356,7 +2356,7 @@ static ssize_t timerslack_ns_write(struct file *file, > const char __user *buf, > return -ESRCH; > > if (p != current) { > - if (!capable(CAP_SYS_NICE)) { > + if (!ns_capable(file->f_cred->user_ns, CAP_SYS_NICE)) { > count = -EPERM; > goto out; > } > @@ -2393,7 +2393,7 @@ static int timerslack_ns_show(struct seq_file *m, void > *v) > > if (p != current) { > > - if (!capable(CAP_SYS_NICE)) { > + if (!ns_capable(seq_user_ns(m), CAP_SYS_NICE)) { > err = -EPERM; > goto out; > }
Looks reasonable to me. Acked-by: John Stultz <john.stu...@linaro.org> thanks -john