Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp454921ybf; Fri, 28 Feb 2020 01:09:09 -0800 (PST) X-Google-Smtp-Source: APXvYqwrg6ySGBgpt3x2zGTnKXnKV+YWF8KoHY7jiVwlb4FpTovAQ9S5DylBXR7OD7f291i4Ti5f X-Received: by 2002:a05:6830:128e:: with SMTP id z14mr2419556otp.184.1582880949407; Fri, 28 Feb 2020 01:09:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582880949; cv=none; d=google.com; s=arc-20160816; b=Krmca1iWZ2D1LIm31C1T3fvgn0z4P/0RzLdY35XgkVGmU7TvW6bGbC1RK4R8EjYP3K LAulbv66jjx0fZlaFEiFBcSvI8BWvdyLxPWGjovSQQiWQ5DtX0ML/932dpRkcyVUBVpU 2scs+l0+/zaLNuYyZCXyFNxDQcEpuYwWGZABq7clIJ4wuzQfU4O0WACHYqwn3kuH9onk HXMAEX66wlifQg8o96Dpvo9HT//2La89Q+BiXnAN8HOoGwudPCG3eftLJQZtD4qo4mAf sQqv9LdOv1uwGYWS8Sl2IT5RRZHWnU4EUYZs3ciLdHfBZc+ToBtm/3vuH8Tbwo281lrw 7xtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from; bh=/rNHtWCgNKDP4cgH7t2BBvkL0j9QBy8crmzQTxEfzDo=; b=XRKJF46hgiTe3kUoZYFocHBdkWO7gVwHdXCLZCI/gvcJyZbcNSCVQJO4ijULQ4MyW7 7GHWQQjhBuZFrDXAvZqZGaz5FAiQvKDNzGooG6YKvJj0vZFmFxep57d/fjki6gYTM98k Dm3UdNqxGOJeiIFAx3wRF+qJZQLH4V1OQWvlTEVlOswEJSq4VNKZStOt4kvcyfQXOS6W FoAe46rGQgigyyIE2HLEgqSm+o+UKKrIJe9ef/kvel9z+rSvI9iJ7YBnU2RX1qpdzxTl IHTYKgA48QuCSOayRvoFST2zVvFREj7gXe+ydyFyLfw4Q8YuyFtHXuloIjlAKtLFEHHV bNlQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p22si1255731ota.43.2020.02.28.01.08.57; Fri, 28 Feb 2020 01:09:09 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726871AbgB1JIV (ORCPT + 99 others); Fri, 28 Feb 2020 04:08:21 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:57606 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726796AbgB1JIT (ORCPT ); Fri, 28 Feb 2020 04:08:19 -0500 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 01S91Tqf060474 for ; Fri, 28 Feb 2020 04:08:18 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0b-001b2d01.pphosted.com with ESMTP id 2yepx4f1jb-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 28 Feb 2020 04:08:18 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 28 Feb 2020 09:08:16 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 28 Feb 2020 09:08:11 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 01S98A7w53674042 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Feb 2020 09:08:10 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 49B17AE058; Fri, 28 Feb 2020 09:08:10 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 92E12AE053; Fri, 28 Feb 2020 09:08:07 +0000 (GMT) Received: from localhost.in.ibm.com (unknown [9.124.35.18]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 28 Feb 2020 09:08:07 +0000 (GMT) From: Parth Shah To: linux-kernel@vger.kernel.org Cc: peterz@infradead.org, mingo@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, qais.yousef@arm.com, chris.hyser@oracle.com, pkondeti@codeaurora.org, patrick.bellasi@matbug.net, valentin.schneider@arm.com, David.Laight@ACULAB.COM, pjt@google.com, pavel@ucw.cz, tj@kernel.org, dhaval.giani@oracle.com, qperret@google.com, tim.c.chen@linux.intel.com Subject: [PATCH v5 4/4] sched/core: Add permission checks for setting the latency_nice value Date: Fri, 28 Feb 2020 14:37:55 +0530 X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200228090755.22829-1-parth@linux.ibm.com> References: <20200228090755.22829-1-parth@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 20022809-0028-0000-0000-000003DECBEA X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20022809-0029-0000-0000-000024A3EDFB Message-Id: <20200228090755.22829-5-parth@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-02-28_02:2020-02-26,2020-02-28 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=1 phishscore=0 priorityscore=1501 bulkscore=0 mlxlogscore=999 malwarescore=0 impostorscore=0 clxscore=1015 mlxscore=0 adultscore=0 spamscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002280075 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since the latency_nice uses the similar infrastructure as NICE, use the already existing CAP_SYS_NICE security checks for the latency_nice. This should return -EPERM for the non-root user when trying to set the task latency_nice value to any lower than the current value. Signed-off-by: Parth Shah Reviewed-by: Chris Hyser --- kernel/sched/core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index cd1fb9c8be26..564b3a2036d4 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -4875,6 +4875,10 @@ static int __sched_setscheduler(struct task_struct *p, return -EINVAL; if (attr->sched_latency_nice < MIN_LATENCY_NICE) return -EINVAL; + /* Use the same security checks as NICE */ + if (attr->sched_latency_nice < p->latency_nice && + !capable(CAP_SYS_NICE)) + return -EPERM; } if (pi) -- 2.17.2