Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3072093ybc; Mon, 18 Nov 2019 09:05:57 -0800 (PST) X-Google-Smtp-Source: APXvYqzrAZ8Ms5PkG9oaAhzdnNA99HZ43Yg/+dwj5EbD22f0tHt6oWl8PEeFFoH7D+84xeCU2lkm X-Received: by 2002:a17:906:2615:: with SMTP id h21mr28185498ejc.212.1574096757449; Mon, 18 Nov 2019 09:05:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574096757; cv=none; d=google.com; s=arc-20160816; b=hRdJQ7qxiZLZPkCaOoez3TAMrb2GYk7S+LxBfbkz4MPRBwtKJ58NDzrG0x/v52s6o8 6qM94JPD44jDkSRPibsGpEvGL9KwTgv2rJ6aI2i8piz6nyHQT2XnaqE+iQkZLKh3ILep Rw+Y8Oos6mRN8w+ZT52IiLkTZ+IISuMZC+bGFyw2u0YiNJ8bY5F6hkPrlVfEiVj1SOcu Iv6ihpu9Eg6Pq5nS1dAZLvD0Zh0gouVibhYYkbPyM6TIO8xJZrD7rfyXzvFHApLyIwOb jN0acovimO3x5C2KP7HX1SeSUpZwFU3A8zlbBLoal3uviUePSLmJqX83rYyYtNS7E2QC y6HQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=PTkoEEtcL3+nuIHWxsynGo3Qi7g5cwPRqx/QuAOHMmw=; b=rhY44Mpq3lc1YdkAEAQdiqslMUY9cMQBnhgPOSkAhfWn7C2KClWyFEjBKwJ+wgYhqU nD2zDSQxghQ2Err7fCpFBm3MvKqUezDXJyfNQoF1OsnNjCzxUi+0O8H5I662dTNo7fGd vILFF3IwXEcW+ZvOveEe9BmGOqXrHADzQOkp13NqvgyfZT5RXjybiW9ALVivvZE0Fh7P SNcnRoEPTrIg48HcddNY+E1RdDnhRRQwlqEqZvXaYPVValA8Pzi44z0z+sh7xe6acc+b Mq0vwEnh9Sz8KcLNJWz98vr94bQN/z1WC18fG23VwfrYrPWdzIiGLGYzzwlTimcGZ7SN xOKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=DMdl7W9u; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s13si11847134ejx.144.2019.11.18.09.05.23; Mon, 18 Nov 2019 09:05:57 -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=@oracle.com header.s=corp-2019-08-05 header.b=DMdl7W9u; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726677AbfKRREU (ORCPT + 99 others); Mon, 18 Nov 2019 12:04:20 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:34490 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726716AbfKRRET (ORCPT ); Mon, 18 Nov 2019 12:04:19 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAIGwxS9155920; Mon, 18 Nov 2019 17:03:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=PTkoEEtcL3+nuIHWxsynGo3Qi7g5cwPRqx/QuAOHMmw=; b=DMdl7W9uC9bqWZ/epKz37dhIwooSf9lLNXdhJnsKb/u+bJ7zO6dXZIL52syfwpqlbGRK ImsbX6fBSuEV3IUFbeWi2UVJrS9wCncOBAGYJ/6QqiG5fJ2bHK7zxTCOyA98Io55YSc4 dHDW1KVf9FtvbhqYNVhUOBkrl6Fd21SIlPP/N0AK1wXi2pDVQHRqJ8zH4NwpLKMP08qd ly6yLKUrtxVG/16AcSiVOQ3mrq5DzBH7OAI6I8A3sqR3t7AY9w3YRIKkAzXkhdicBtXb 1zRajWFLm/OIaO8zGwZ4lg9xcv1V3w3FwImA6X+SfjEV7OcKf6OaknOVSh1eh/GUphdE XA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2wa8hthmst-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Nov 2019 17:03:48 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xAIGwbwK159204; Mon, 18 Nov 2019 17:03:47 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 2wbxm2tjtd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Nov 2019 17:03:47 +0000 Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id xAIH3ksF022683; Mon, 18 Nov 2019 17:03:47 GMT Received: from pp-ThinkCentre-M82.us.oracle.com (/10.132.95.199) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 18 Nov 2019 09:03:46 -0800 From: Prakash Sangappa To: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org Cc: ebiederm@xmission.com, tglx@linutronix.de, peterz@infradead.org, serge@hallyn.com, prakash.sangappa@oracle.com Subject: [RESEND RFC PATCH 1/1] Selectively allow CAP_SYS_NICE capability inside user namespaces Date: Mon, 18 Nov 2019 09:01:18 -0800 Message-Id: <1574096478-11520-2-git-send-email-prakash.sangappa@oracle.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1574096478-11520-1-git-send-email-prakash.sangappa@oracle.com> References: <1574096478-11520-1-git-send-email-prakash.sangappa@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9445 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=12 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180149 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9445 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=4 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-1911180149 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allow CAP_SYS_NICE to take effect for processes having effective uid of a root user from init namespace. Signed-off-by: Prakash Sangappa --- kernel/sched/core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 7880f4f..628bd46 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -4548,6 +4548,8 @@ int can_nice(const struct task_struct *p, const int nice) int nice_rlim = nice_to_rlimit(nice); return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) || + (ns_capable(__task_cred(p)->user_ns, CAP_SYS_NICE) && + uid_eq(current_euid(), GLOBAL_ROOT_UID)) || capable(CAP_SYS_NICE)); } @@ -4784,7 +4786,9 @@ static int __sched_setscheduler(struct task_struct *p, /* * Allow unprivileged RT tasks to decrease priority: */ - if (user && !capable(CAP_SYS_NICE)) { + if (user && !(ns_capable(__task_cred(p)->user_ns, CAP_SYS_NICE) && + uid_eq(current_euid(), GLOBAL_ROOT_UID)) && + !capable(CAP_SYS_NICE)) { if (fair_policy(policy)) { if (attr->sched_nice < task_nice(p) && !can_nice(p, attr->sched_nice)) -- 2.7.4