[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87in1pn9d0.fsf@xmission.com>
Date: Thu, 25 Oct 2018 13:56:27 -0500
From: ebiederm@...ssion.com (Eric W. Biederman)
To: bmgordon@...gle.com
Cc: linux-kernel@...r.kernel.org, John Stultz <john.stultz@...aro.org>,
Kees Cook <keescook@...omium.org>,
"Serge E. Hallyn" <serge@...lyn.com>,
Thomas Gleixner <tglx@...utronix.de>,
Arjan van de Ven <arjan@...ux.intel.com>,
Oren Laadan <orenl@...lrox.com>,
Ruchi Kandoi <kandoiruchi@...gle.com>,
Rom Lemarchand <romlem@...roid.com>,
Todd Kjos <tkjos@...gle.com>, Colin Cross <ccross@...roid.com>,
Nick Kralevich <nnk@...gle.com>,
Dmitry Shmidt <dimitrysh@...gle.com>,
Elliott Hughes <enh@...gle.com>,
Android Kernel Team <kernel-team@...roid.com>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH] proc: use ns_capable instead of capable for timerslack_ns
bmgordon@...gle.com writes:
> From: Benjamin Gordon <bmgordon@...gle.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.
The goal seems legitimate. However the permission checks look wrong.
In particular the choice of user namespace should be
"p->cred->user_ns". This will limit this to tasks that have
CAP_SYS_NICE in the same namespace as the task that is being modified.
Testing file->f_cred->user_ns it is testing whoever opened the file and
that could be anyone.
Eric
> Signed-off-by: Benjamin Gordon <bmgordon@...gle.com>
> Cc: John Stultz <john.stultz@...aro.org>
> Cc: Kees Cook <keescook@...omium.org>
> Cc: "Serge E. Hallyn" <serge@...lyn.com>
> Cc: Thomas Gleixner <tglx@...utronix.de>
> Cc: Arjan van de Ven <arjan@...ux.intel.com>
> Cc: Oren Laadan <orenl@...lrox.com>
> Cc: Ruchi Kandoi <kandoiruchi@...gle.com>
> Cc: Rom Lemarchand <romlem@...roid.com>
> Cc: Todd Kjos <tkjos@...gle.com>
> Cc: Colin Cross <ccross@...roid.com>
> Cc: Nick Kralevich <nnk@...gle.com>
> Cc: Dmitry Shmidt <dimitrysh@...gle.com>
> Cc: Elliott Hughes <enh@...gle.com>
> Cc: Android Kernel Team <kernel-team@...roid.com>
> Cc: Andrew Morton <akpm@...ux-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;
> }
Powered by blists - more mailing lists