Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp479049imm; Mon, 21 May 2018 09:04:02 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq/BSxCtdrjFAve8H05Lb7ZUbuSahE7EMWOtbu3QjuFetUBAbCCbpjJNoGeEJBOi7sbRnvI X-Received: by 2002:a17:902:8f95:: with SMTP id z21-v6mr21202727plo.259.1526918642409; Mon, 21 May 2018 09:04:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526918642; cv=none; d=google.com; s=arc-20160816; b=YN/ZPyMz0jU0PeE0C2bW3WKTtANkHK2mOk7wpBVAUxCranb4Q/26Hv5qTI13PdA5rr y8LIourJj0GVOmPe/slK0ssGaODNaO0cfDw7xtEikD3mesRWYG/SC5/Y+4BPg7/Tqkwp XFhcuK1c57eR/WfdjV7m+IUndtrN+3tFGqVyP8fuEY8USHeIcAYDsvBaHgRbonQUM8lI sK5IWBRaRoPERvD2MiQQErZF5W2IXQTLfEPmM2X44AUAj8gg0ytbcyaSHMsdEVEtovNN 5WzJOePMBSglJ5i1HT2cdNANMk1A7xpSCCGf1qRHFNqRFwIH/pWOmfegdW2FSBtZMaMj iNPg== 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:arc-authentication-results; bh=+v5FmwcOA7inskjXpBBr9OZfdKmnP9vx/z8vXaMNGmg=; b=Uw/i90ZP1XHkO28fml0FMVf2xuHXHYOGZkXTITHGo1rlCngvJm1IygO1+8XgZtSnlh gYDU+E15HEsIMsvJRxLHzZCePHgA09H+aeegVrZVwj9wfcbF8IGEYR6vx1raUeP0hKmh oO7rYx8pk92RUz1FU/L9AlGb06nK6Mu6KwRaK/tUiciO5cpBK33vYVt2t4Mn7jSD44ig RP9F8mUkLytTMWRHL/LfnMVkRHOVx4scssqLB/7IH0y452imyo8JTU9P1UsDIZkLHJuz VSotsbVmgjapsPtBYu7CcE4KXvOdhgKFNZgZaX8QZZPBkmEGx7perwUS/aFdcsGwkMD6 /3QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=YE0/grRe; 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 m11-v6si8834441pgv.608.2018.05.21.09.03.24; Mon, 21 May 2018 09:04:02 -0700 (PDT) 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=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=YE0/grRe; 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 S1753010AbeEUQCg (ORCPT + 99 others); Mon, 21 May 2018 12:02:36 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:59151 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752092AbeEUQC2 (ORCPT ); Mon, 21 May 2018 12:02:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1526918549; x=1558454549; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=Dmaa0IlF6rEyE4+tQeNgBQp4t2iO+qPHONBbECf3eds=; b=YE0/grReyoeGu3jPINp2o4bdsFCdbC3tixkhs65nVl0QmEdqKhWATRt4 9aj5VhVy5SHsNUG7e/5C9wDjM1CSM1hjk7h1nsqKDSgshnuVe6ZXVyPXp ruCpnH6HDtGPEyfzvGjL6K2sZMv1KE0MB1JMT8cn38yaGU5HphIAoJqd2 rx3IZFyGkZmN857MJCQ9J0elfJYrnBthhnd6ZDvfKxnYKlUteHglOd5/r svoVaONJtA6hcjhsw9ahYUO1/rBz8Npz0gbgiK4T8Y7BVgkQIfN1/edUG e+kf8iIyLiich+37IRBcopQFGA+uZWMmfH/Xw9pFTnizhO/O1OlXXcsxX g==; X-IronPort-AV: E=Sophos;i="5.49,426,1520870400"; d="scan'208";a="79445383" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 22 May 2018 00:02:28 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 21 May 2018 08:53:25 -0700 Received: from penguito-adamm.sdcorp.global.sandisk.com ([10.11.47.13]) by uls-op-cesaip02.wdc.com with ESMTP; 21 May 2018 09:02:28 -0700 From: adam.manzanares@wdc.com To: viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, axboe@kernel.dk, bcrl@kvack.org Cc: tglx@linutronix.de, mingo@kernel.org, pombredanne@nexb.com, kstewart@linuxfoundation.org, gregkh@linuxfoundation.org, bigeasy@linutronix.de, jack@suse.cz, darrick.wong@oracle.com, rgoldwyn@suse.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-aio@kvack.org, linux-api@vger.kernel.org, hch@infradread.org, Adam Manzanares Subject: [PATCH v5 1/5] block: add ioprio_check_cap function Date: Mon, 21 May 2018 09:01:43 -0700 Message-Id: <20180521160147.2372-2-adam.manzanares@wdc.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180521160147.2372-1-adam.manzanares@wdc.com> References: <20180521160147.2372-1-adam.manzanares@wdc.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Adam Manzanares Aio per command iopriority support introduces a second interface between userland and the kernel capable of passing iopriority. The aio interface also needs the ability to verify that the submitting context has sufficient priviledges to submit IOPRIO_RT commands. This patch creates the ioprio_check_cap function to be used by the ioprio_set system call and also by the aio interface. Signed-off-by: Adam Manzanares Reviewed-by: Christoph Hellwig --- block/ioprio.c | 22 ++++++++++++++++------ include/linux/ioprio.h | 2 ++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/block/ioprio.c b/block/ioprio.c index 6f5d0b6625e3..f9821080c92c 100644 --- a/block/ioprio.c +++ b/block/ioprio.c @@ -61,15 +61,10 @@ int set_task_ioprio(struct task_struct *task, int ioprio) } EXPORT_SYMBOL_GPL(set_task_ioprio); -SYSCALL_DEFINE3(ioprio_set, int, which, int, who, int, ioprio) +int ioprio_check_cap(int ioprio) { int class = IOPRIO_PRIO_CLASS(ioprio); int data = IOPRIO_PRIO_DATA(ioprio); - struct task_struct *p, *g; - struct user_struct *user; - struct pid *pgrp; - kuid_t uid; - int ret; switch (class) { case IOPRIO_CLASS_RT: @@ -92,6 +87,21 @@ SYSCALL_DEFINE3(ioprio_set, int, which, int, who, int, ioprio) return -EINVAL; } + return 0; +} + +SYSCALL_DEFINE3(ioprio_set, int, which, int, who, int, ioprio) +{ + struct task_struct *p, *g; + struct user_struct *user; + struct pid *pgrp; + kuid_t uid; + int ret; + + ret = ioprio_check_cap(ioprio); + if (ret) + return ret; + ret = -ESRCH; rcu_read_lock(); switch (which) { diff --git a/include/linux/ioprio.h b/include/linux/ioprio.h index 627efac73e6d..4a28cec49ec3 100644 --- a/include/linux/ioprio.h +++ b/include/linux/ioprio.h @@ -77,4 +77,6 @@ extern int ioprio_best(unsigned short aprio, unsigned short bprio); extern int set_task_ioprio(struct task_struct *task, int ioprio); +extern int ioprio_check_cap(int ioprio); + #endif -- 2.15.1