Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3471284imj; Mon, 11 Feb 2019 22:23:01 -0800 (PST) X-Google-Smtp-Source: AHgI3IZOdXW69vli+A0iV2PbUzTdffM4EsUBw1/D5tFOcVpvUppC1JJy69LW0IOEeEGhVJ62p7q+ X-Received: by 2002:a17:902:9008:: with SMTP id a8mr2449420plp.38.1549952581580; Mon, 11 Feb 2019 22:23:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549952581; cv=none; d=google.com; s=arc-20160816; b=g+Vk8U0y2dZnHasfBUtFZ3ZiarENsos9tY4zu746inDZ/zZNwH87G+cqaCtblIFznG s9zbjLs1g1zkzRrfOK3dLhA5L3OjTJRYJJzTNwPXV6wEwmfJC9Iy9B2yfkx7LZjPd9Qj AdLhAulVwTb48UM60k8+AvTfB/kMqYKgApj8vuUVRb7kBLJ68Rtp+4BV+NBCFPRGS4Sd qUVzg6CK2OGfuDeuI7BMRjPMivQjelg8iPeBiun/+C2EcBHjoXd7cRm0ADqp3UhNRFBA 67soymmVVwEmtnYwK/9E3yVRATByLAQnEe9hUofqSRruZVhta8omQvOTnl+pUDXXa0/c +IKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Pl37sUB+5LKEdNhDirBdFh/mNbW0Qy2VYKgpIeNrnhM=; b=S6yqDvy/Ui0sq1QrQkSgvLzhsxncrqMOuqVeJo13GztE33UFQW+6AFiHfj2h6llAW7 yVO5eH7PNtK3OdV2Wm9H5Nwch57GS2916Tb+EKp5Z7sfzAaJ0hr6E35P5ej8Pvh3AarO lDhrrI9KotlrW9neEiz7R+PCltazCcek6ZmrqMVGM6oJKFi+Wsu1Ta4VVrn8ZUE+u2by trNaBOfKo/LsFoBtZ/eOxoDG4e8UvcqX/BnT72pyL7CoOOlyiQuyJRtD7D1adHOYXVfB 6kHX7fFnUq67SLB7B37DkzRmSmbl5et2GykucpJbXORIk69jTqJf7TVdoCtZP/E4ZvG4 nvLA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 72si12560475plb.224.2019.02.11.22.22.45; Mon, 11 Feb 2019 22:23:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727004AbfBLGWj (ORCPT + 99 others); Tue, 12 Feb 2019 01:22:39 -0500 Received: from mail.hallyn.com ([178.63.66.53]:44030 "EHLO mail.hallyn.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725916AbfBLGWj (ORCPT ); Tue, 12 Feb 2019 01:22:39 -0500 Received: by mail.hallyn.com (Postfix, from userid 1001) id 9FD7463C; Tue, 12 Feb 2019 00:22:36 -0600 (CST) Date: Tue, 12 Feb 2019 00:22:36 -0600 From: "Serge E. Hallyn" To: "Eric W. Biederman" Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Benjamin Gordon , John Stultz , Kees Cook , "Serge E. Hallyn" , Thomas Gleixner , Arjan van de Ven , Oren Laadan , Ruchi Kandoi , Rom Lemarchand , Todd Kjos , Colin Cross , Nick Kralevich , Dmitry Shmidt , Elliott Hughes , Alexey Dobriyan , Andrew Morton , Linus Torvalds , Sasha Levin Subject: Re: [PATCH 4.20 282/352] fs/proc/base.c: use ns_capable instead of capable for timerslack_ns Message-ID: <20190212062236.GA26652@mail.hallyn.com> References: <20190211141846.543045703@linuxfoundation.org> <20190211141904.885459037@linuxfoundation.org> <87tvh9es4x.fsf@xmission.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87tvh9es4x.fsf@xmission.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 11, 2019 at 07:02:06PM -0600, Eric W. Biederman wrote: > Greg Kroah-Hartman writes: > > > 4.20-stable review patch. If anyone has any objections, please let me > > know. > > No objection. But I think of this as a feature addition rather than a > fix for something. As a feature that we now allow something we > previously did not does this qualify for a backport to stable? Hi, I had the exact same thought when I saw this this morning, and was planning on replying tonight. > It is probably no more harmful in this instance than adding PCI IDs to a > driver. So I am not worried. I am curious the current guidelines > are. > > In most cases a small relaxation of permissions like this requires a lot > of bug fixing as typically code protected by capable(CAP_XXX) has been > written and tested assuming a trusted root user. Those bug fixes are > many times too large for a stable backport. > > Eric > > > > ------------------ > > > > [ Upstream commit 8da0b4f692c6d90b09c91f271517db746a22ff67 ] > > > > 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/20181030180012.232896-1-bmgordon@google.com > > Signed-off-by: Benjamin Gordon > > Acked-by: "Eric W. Biederman" > > Cc: John Stultz > > Cc: "Eric W. Biederman" > > Cc: Kees Cook > > Cc: "Serge E. Hallyn" > > Cc: Thomas Gleixner > > Cc: Arjan van de Ven > > Cc: Oren Laadan > > Cc: Ruchi Kandoi > > Cc: Rom Lemarchand > > Cc: Todd Kjos > > Cc: Colin Cross > > Cc: Nick Kralevich > > Cc: Dmitry Shmidt > > Cc: Elliott Hughes > > Cc: Alexey Dobriyan > > Signed-off-by: Andrew Morton > > Signed-off-by: Linus Torvalds > > Signed-off-by: Sasha Levin > > --- > > fs/proc/base.c | 12 +++++++++--- > > 1 file changed, 9 insertions(+), 3 deletions(-) > > > > diff --git a/fs/proc/base.c b/fs/proc/base.c > > index ce3465479447..98525af0953e 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;