From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752132AbbIQV32 (ORCPT ); Thu, 17 Sep 2015 17:29:28 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:51306 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750792AbbIQV31 (ORCPT ); Thu, 17 Sep 2015 17:29:27 -0400 Date: Thu, 17 Sep 2015 14:29:26 -0700 From: Andrew Morton To: bsegall@google.com Cc: linux-kernel@vger.kernel.org, Oleg Nesterov , Al Viro , "Eric W. Biederman" Subject: Re: [PATCH] pidns: fix set/getpriority and ioprio_set/get in PRIO_USER mode Message-Id: <20150917142926.1a68072b19ef0ada47eabe43@linux-foundation.org> In-Reply-To: References: X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 16 Sep 2015 12:58:04 -0700 bsegall@google.com wrote: > setpriority(PRIO_USER, 0, x) will change the priority of tasks outside > of the current pid namespace. This is in contrast to both the other > modes of setpriority and the example of kill(-1). Fix this. getpriority > and ioprio have the same failure mode, fix them too. (cc Eric) > Signed-off-by: Ben Segall > Cc: Oleg Nesterov > Cc: Al Viro > --- > block/ioprio.c | 6 ++++-- > kernel/sys.c | 4 ++-- > 2 files changed, 6 insertions(+), 4 deletions(-) > > diff --git a/block/ioprio.c b/block/ioprio.c > index 31666c9..cc7800e 100644 > --- a/block/ioprio.c > +++ b/block/ioprio.c > @@ -123,7 +123,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which, int, who, int, ioprio) > break; > > do_each_thread(g, p) { > - if (!uid_eq(task_uid(p), uid)) > + if (!uid_eq(task_uid(p), uid) || > + !task_pid_vnr(p)) > continue; > ret = set_task_ioprio(p, ioprio); > if (ret) > @@ -220,7 +221,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which, int, who) > break; > > do_each_thread(g, p) { > - if (!uid_eq(task_uid(p), user->uid)) > + if (!uid_eq(task_uid(p), user->uid) || > + !task_pid_vnr(p)) > continue; > tmpio = get_task_ioprio(p); > if (tmpio < 0) > diff --git a/kernel/sys.c b/kernel/sys.c > index fa2f2f6..6af9212 100644 > --- a/kernel/sys.c > +++ b/kernel/sys.c > @@ -222,7 +222,7 @@ SYSCALL_DEFINE3(setpriority, int, which, int, who, int, niceval) > goto out_unlock; /* No processes for this user */ > } > do_each_thread(g, p) { > - if (uid_eq(task_uid(p), uid)) > + if (uid_eq(task_uid(p), uid) && task_pid_vnr(p)) > error = set_one_prio(p, niceval, error); > } while_each_thread(g, p); > if (!uid_eq(uid, cred->uid)) > @@ -290,7 +290,7 @@ SYSCALL_DEFINE2(getpriority, int, which, int, who) > goto out_unlock; /* No processes for this user */ > } > do_each_thread(g, p) { > - if (uid_eq(task_uid(p), uid)) { > + if (uid_eq(task_uid(p), uid) && task_pid_vnr(p)) { > niceval = nice_to_rlimit(task_nice(p)); > if (niceval > retval) > retval = niceval; > -- > 2.6.0.rc0.131.gf624c3d > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/