From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932573AbbIURyT (ORCPT ); Mon, 21 Sep 2015 13:54:19 -0400 Received: from out02.mta.xmission.com ([166.70.13.232]:51932 "EHLO out02.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932420AbbIURyP (ORCPT ); Mon, 21 Sep 2015 13:54:15 -0400 From: ebiederm@xmission.com (Eric W. Biederman) To: Andrew Morton Cc: bsegall@google.com, linux-kernel@vger.kernel.org, Oleg Nesterov , Al Viro , Linux Containers References: <20150917142926.1a68072b19ef0ada47eabe43@linux-foundation.org> Date: Mon, 21 Sep 2015 12:46:56 -0500 In-Reply-To: <20150917142926.1a68072b19ef0ada47eabe43@linux-foundation.org> (Andrew Morton's message of "Thu, 17 Sep 2015 14:29:26 -0700") Message-ID: <874minis1b.fsf@x220.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-AID: U2FsdGVkX1/bDYLzEk1NI5AXBfrK7CmmCAxQgl1JNhs= X-SA-Exim-Connect-IP: 67.3.201.231 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.7 XMSubLong Long Subject * 0.0 TVD_RCVD_IP Message was received from an IP address * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.4999] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa01 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject * 0.2 T_XMDrugObfuBody_14 obfuscated drug references X-Spam-DCC: XMission; sa01 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;Andrew Morton X-Spam-Relay-Country: X-Spam-Timing: total 694 ms - load_scoreonly_sql: 0.05 (0.0%), signal_user_changed: 4.1 (0.6%), b_tie_ro: 3.0 (0.4%), parse: 1.31 (0.2%), extract_message_metadata: 33 (4.7%), get_uri_detail_list: 5 (0.7%), tests_pri_-1000: 12 (1.7%), tests_pri_-950: 1.98 (0.3%), tests_pri_-900: 1.59 (0.2%), tests_pri_-400: 41 (5.9%), check_bayes: 39 (5.6%), b_tokenize: 15 (2.2%), b_tok_get_all: 12 (1.8%), b_comp_prob: 4.7 (0.7%), b_tok_touch_all: 3.2 (0.5%), b_finish: 0.91 (0.1%), tests_pri_0: 587 (84.6%), tests_pri_500: 7 (1.0%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH] pidns: fix set/getpriority and ioprio_set/get in PRIO_USER mode X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Wed, 24 Sep 2014 11:00:52 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Andrew Morton writes: > 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) (cc Containers) Interesting. Strictly speaking the current behavior is not wrong. Searching for all threads with a given uid has nothing to do with pids so the pid namespace not limiting them is natural. In practice I don't think anyone cares either way (except people with one color or another of security hat on) so this might be a change we can actually make. In general it is probably better not to share uids and gids between containers. Ben do you have a use case where this actually matters? Or was this a case of "That looks wrong..."? 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/