Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2661219imj; Mon, 11 Feb 2019 06:38:12 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibwq8bkfWNu+EZg972mrIOUwXCmprkuvXkhCl0H2RlvRAD2SxThFM1r7tJ0Xa96Atf+tuzh X-Received: by 2002:a17:902:6bc3:: with SMTP id m3mr25835535plt.24.1549895892716; Mon, 11 Feb 2019 06:38:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549895892; cv=none; d=google.com; s=arc-20160816; b=rGzDxhlPK1aYsiUIrFU3DDqqqf9Af9naJcfkpw7luiF7BX2E6IigYikKVu121FAPtf m54OskNh44BRqLt+eiocT4GWHWkd9PL9ZAwMqL3BJWcsptZQnDU+XLHLYSQHxLDK9W8K IYjdYolqXubpq85Knm3FvQRIvhzhb5DPDogxRU2yTqnuX46iUyzAZdNeEpOzVajv24r8 Hcq2TU+jsnKbDtNW63Y6TfgwEPHg9UCcPIxRT05z9Jyb8jVlk5JXIMxEQeCraPHdFUk+ +r3FOxVKWMR/1lsQk6Z5YrK20mMQu/LSoE4xDI0B9DX3BakKTnN/v4ZmMVzta/yjWdoS 0k5g== 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=+POojxkMWsWHNJMpZbRRJm7P2vHGbSL1252Bm/Ul+ac=; b=ix06ckmXvIRYb/q0782XsbtBdxcZsoKOBG1RrLkmMdVuvWaknelPnpY6bpLDbcZ9dj c/umI5tCyJxb5lRXpt8fJG6wFEM5HeOW9EQot1GsUc14OkKM/i1YGR+fbcIUVxxr0/I/ sccUwQUnoM6U/y1P8CxKu2YUrKbKc24qP0mzYudIT/yVk8WUNNvusoUR23dlu/tAdFzG JJYg1PqoqHHPNPT56Ac0xtsqmcLy9gvuT++FXVjP5nxu3+NVIA8wKaZZLdILp2PNPqFG TiA8CHG6aUsQPdE0UxdPiITi6gE3y1oiZI+PwhjVCOd8PzCdxeEOwXsBpJIvZmIEHA2a lrNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="kC2vtS/N"; 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 v11si10619412plo.377.2019.02.11.06.37.56; Mon, 11 Feb 2019 06:38:12 -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="kC2vtS/N"; 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 S1726827AbfBKOfv (ORCPT + 99 others); Mon, 11 Feb 2019 09:35:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:44534 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731112AbfBKOfs (ORCPT ); Mon, 11 Feb 2019 09:35:48 -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 C305320700; Mon, 11 Feb 2019 14:35:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895747; bh=neWf4RQVzFBxfFot5Cf+CP3nX2xICvTTyVgxkyVOMCU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kC2vtS/N7Zg/YAcK3UKJCwmacE3Ywt4VM22iz/GXDkIRc/zGs6JWJ0ZQsc4kAhT/x YptSLHTDModa0fMCKMm6FMjTc9f84YJjTFmD2nKa1HHCBj58l16pd3ZEaRnekuded8 +fCZc70OSzLyVBE12ywxF9p6QQci/zLQwo/IoIos= 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.20 282/352] fs/proc/base.c: use ns_capable instead of capable for timerslack_ns Date: Mon, 11 Feb 2019 15:18:29 +0100 Message-Id: <20190211141904.885459037@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@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.20-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 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; -- 2.19.1