Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2202939ybv; Mon, 24 Feb 2020 01:00:53 -0800 (PST) X-Google-Smtp-Source: APXvYqzNYtromRlqHlgrXEPJpWAFpvEJ2sg1ytxwi7SjS0B8LSPi0poWhs8U7vaXmy7OTzQLlYsU X-Received: by 2002:a05:6830:18ce:: with SMTP id v14mr38275966ote.36.1582534853009; Mon, 24 Feb 2020 01:00:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582534853; cv=none; d=google.com; s=arc-20160816; b=KTfDse0lobvvec3w5Dx0T+zAdf5AQ/UQHXpGzUvMo4IXfSlo1qsprbwvuCWiSY5G4J oMvKAnz3hk2Nv1tdaY3BtWOrCEgMKeLq+h6MXMiVErluaV+im9j+Gpc5JdNQ0X7Ro0Eu dCSbFF4yJr3c7x94CQYcviEp4Q4L5v3RnKhcfmPCD9eNT3nI2h0BCQI4f/ndkqRbWZTS X3ww7d1rNmsJi9BUnpxOkh4g9z4cuNwPJslMiNsc6Wg0fLTpggoQODi+meg8XgTfmODW 1RIW3EjNnjUpAVFH1iBAcwyS7fgBvsqYopnVjrUFO9Itdg+p3r00cLzIsXc8A6XrK65R 9hnw== 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=69rqNwCFLOMXExmDh8DwB64t1bhMAjcb258Fs+QHunw=; b=E1sVEfIaDwv2C/HweoDTNUq3JMb38KfxNIRm+dB1vyCHHpB0wmh62DL49E6SHwL+N4 68l/GpBdiXVOX2ltU+3EaaTX2vUXj/yU8yjRwg/9AsrQydXADap11m6MZkx4y1U+1YVp 4szFAFv6QPPthkUItF8UcURl1X84jFyzkDAsgne3fxIRqU2byEr7uDL9C1LLphYmbroy HhI4HMUtF298uq/53FIHLtIDd/bORrMPVlJvVbGPH9XAsVjIgc5ZSi5S4T7M9mOTw9AU pmNDR0Iz0TphaQyGatUKwk648qWWT528Bxtd0mg5ViXiDrC4A93TiOn2Am08Egq0Gjw1 onEw== 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 p11si5931660ota.300.2020.02.24.01.00.40; Mon, 24 Feb 2020 01:00:52 -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 S1727460AbgBXI7x (ORCPT + 99 others); Mon, 24 Feb 2020 03:59:53 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:21806 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727326AbgBXI7w (ORCPT ); Mon, 24 Feb 2020 03:59:52 -0500 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 01O8xoZQ081710 for ; Mon, 24 Feb 2020 03:59:51 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2yb12agk88-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 24 Feb 2020 03:59:51 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 24 Feb 2020 08:59:39 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) 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) Mon, 24 Feb 2020 08:59:33 -0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 01O8xWP542074134 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Feb 2020 08:59:32 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C7FAF4203F; Mon, 24 Feb 2020 08:59:32 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3E5E242041; Mon, 24 Feb 2020 08:59:30 +0000 (GMT) Received: from localhost.in.ibm.com (unknown [9.124.35.160]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 24 Feb 2020 08:59:30 +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, 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 v4 4/4] sched/core: Add permission checks for setting the latency_nice value Date: Mon, 24 Feb 2020 14:29:18 +0530 X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200224085918.16955-1-parth@linux.ibm.com> References: <20200224085918.16955-1-parth@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 20022408-0028-0000-0000-000003DD6AB5 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20022408-0029-0000-0000-000024A27EDA Message-Id: <20200224085918.16955-5-parth@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-02-24_02:2020-02-21,2020-02-24 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 bulkscore=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 suspectscore=1 adultscore=0 malwarescore=0 impostorscore=0 phishscore=0 mlxlogscore=961 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002240079 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 --- kernel/sched/core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index e1dc536d4ca3..f883e1d3cd10 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -4887,6 +4887,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 && + !can_nice(p, attr->sched_latency_nice)) + return -EPERM; } if (pi) -- 2.17.2