Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2690068imj; Mon, 11 Feb 2019 07:04:41 -0800 (PST) X-Google-Smtp-Source: AHgI3IZQzj9wjgBKMDSeLKiA8VsgOexykdOrfdlfKYyIHi3xTd3Gem93uwp+7bPKUZXao0cB+75r X-Received: by 2002:a65:4904:: with SMTP id p4mr18964725pgs.384.1549897481882; Mon, 11 Feb 2019 07:04:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549897481; cv=none; d=google.com; s=arc-20160816; b=uXglcPQWk/Xc5r+QGIEYNUCH2kiw2nJXrvVneLXb5rrBX/Z8fcY1YCLdBWGbOy4OXu w7Ez7Yf5dU5FUmC8CCzNoxjG8lPYU2SKy52GyRveLAsQsSII4FT3795BiWwl5TBK5FpX PEWNZbl3MxfOW00FJ2Vk97QJZTOcxq0OMxeVwh92LxQqja1DxqfO8PEz/6K5m9/eHDj5 p3dyinKCbCqliB2FK4O1itBYEcKE7u+Olyp1vI00UUzMOyLPOWD84atjxGjY7kQqMIQL 4+o8zU/kkXA0BaFFWLrtDlp/zNkCfLywmuS0a2ipXVpaNOH7b63QcfTE4+xsvaULw0f9 WIgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=i1KZ/acVK7YjeqBt3al6TlD8xVetVBIGop/DvKOlSVc=; b=mvk7O7jnvxPQCZdT2+5OD0dlK2R06QaEHN1M6dB3ZjWgzo59zq0EG+jb9bHGEGC+Z/ x/H34m7sCcXB2mX/F9Xn5hpDPbehXfZICHOY3uRasA+vZ5+e9RnIHgsUkIGeUQXyJTKK Arnwx3M6Jsl77PH6CE0S3WqKoaElDD9zcCy0aGcoOw8uVxHn995lvxir9r/Ndrb0bd2R vMM358sXPsS3LJj3ntaiCMKFkOtzuiKJffENQvizfm48D0dhQG00bFq0R3JuYrw40NU2 xDx3GcB2xXWZBEXvRd3pSAxjCasTJA6n17b4WpKQn4Jv3sSLvVkSJJuQB1YWdLpjpI/Q Yjwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZGFZhgqu; 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 31si10613027pli.438.2019.02.11.07.04.24; Mon, 11 Feb 2019 07:04:41 -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; dkim=pass header.i=@kernel.org header.s=default header.b=ZGFZhgqu; 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 S2390598AbfBKPDU (ORCPT + 99 others); Mon, 11 Feb 2019 10:03:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:51656 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390580AbfBKPDQ (ORCPT ); Mon, 11 Feb 2019 10:03:16 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 96B89222A7; Mon, 11 Feb 2019 15:03:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549897395; bh=ONOjJsaOCKjQkYA2tyyWrFpf4yEp0NOnyVOm0prXK1c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZGFZhgquzAzieJMyumn3tb9+Dc9n2WPayrYvkT2KfhVLKGwe8hIwXhnkdgxKwsUtu pFCadvtR7bzqNCuodK9CPUKw7e7qoEmQyb68skZjcucF38zsiA6IhW88MUn9F0naur C43+2coGecuh3N6kQFuc9o55nrlaeg9zB3T0oXYw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Benjamin Gordon , "Eric W. Biederman" , 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: [PATCH 4.14 158/205] fs/proc/base.c: use ns_capable instead of capable for timerslack_ns Date: Mon, 11 Feb 2019 15:19:16 +0100 Message-Id: <20190211141838.688916345@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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 9063738ff1f0..e26155a97afa 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -2374,10 +2374,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) { @@ -2410,11 +2413,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; -- 2.19.1