Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3726120imm; Thu, 17 May 2018 13:40:27 -0700 (PDT) X-Google-Smtp-Source: AB8JxZreewrBXHO8lcxIXwFIdd293MIqTQa68zFbJUitMmFXI6XkvODCdKZ4wXJSJJKvz3lzOxNJ X-Received: by 2002:a62:49d7:: with SMTP id r84-v6mr6500982pfi.146.1526589627853; Thu, 17 May 2018 13:40:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526589627; cv=none; d=google.com; s=arc-20160816; b=Wdh5rJChiJIIuA4t05rvEuvlQxUy5uRvyrVnSL4VlTIe7QBxL0Nc+ztNfBkzXCcj5w i5Eq67aub8CvskrKsb7uO0v8H08FZiwJb9K+EPJHYTZkWo58l1CTe3NfDrm2UwckAFR7 9dDTqZl4HICQPLJszQ3QFU3MaAMTKSZrK3AGka+dZfX6PvqkMIVZpTqKSzwcJV+tM4WY m8qvfvcbjMRF5TsiWrD3SlARSQyYdrTg8APEa4/6Qd4ktTR21pTY6HEsdo1zTkVdRwRx MN4a+3PlyHzpb4rYtqFIMZABe9KEWmHB9YqwFimJncuOLB471ON9+C3geyjCa3RqeaiR GVFQ== 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=Ii+S7sdaskP+LnQ9VCODTkgZzTjMFWPfYZPmDlT/AaM=; b=swGUPD/5aSb2/oQ3ZkSVozmL+7r0hA+LTTsPPfkREzIDmPa7Wxe4wpjvX48Cx80lZR OavQzHCn9pML4iF7xf4bBJufpqQM/39mcU+DQZjig0ES+k3K89GH1R6ntBXC84bT4mNg giF5wQmOqWGMN3REY2h+4/uwU6V5u+AgSv/yafOkiyV9qUKlcF4Nndp1jzutrmGmfbIG kZQOvFSSrNgDF3nlwbUGmvCn4oygfXe6t9GdDwbm4CtMddjvjIfPgECdIRuP9eBt5hxK PojZHMDgsjV0eWYXY4VLzUZWAVxq2D9qv3J4sQg4tTQghnZvZHfbQu3uwtu9iM/DVwNo FGmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=qseYRJGV; 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 w63-v6si4519668pgd.32.2018.05.17.13.40.13; Thu, 17 May 2018 13:40:27 -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=qseYRJGV; 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 S1752128AbeEQUia (ORCPT + 99 others); Thu, 17 May 2018 16:38:30 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:60847 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751640AbeEQUi0 (ORCPT ); Thu, 17 May 2018 16:38:26 -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=1526589506; x=1558125506; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=VhkY9dahP0w7hX8nSZ/ahhZiwEaZo6BRX/KgMDBwoEg=; b=qseYRJGVw2BWwOWee0IqJEyuzgYsGxj449KQkJEDODA6UhB2t/IFYUb7 zczUPVqB8Di1NhDwJnnQ7s9KejkJeCVTU7wsi85akbQ+Xs9a0FLB/mPjL XKgjdjXQsWjhIG1iODTaxAedgd1iOJo/RtqJTHrSD/Dx+TAeWlvZvydzF qrWws6PpPqfFhRBzt9PeTIcjTklDKlmq9L3uD9OkW77Z3ot++TAJa+rx/ F7NOeJlqyHwDNgvCExZbCRtN42etPpv0j/1zdd7zR9VXHwzseQkgfquIl jzfXQjVe2qRsawkcYySU/SHx6ZcrmzDi1+ARfWd6yz6xg4u2vIZcAa2Wl A==; X-IronPort-AV: E=Sophos;i="5.49,412,1520870400"; d="scan'208";a="78199742" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 18 May 2018 04:38:25 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 17 May 2018 13:29:28 -0700 Received: from penguito-adamm.sdcorp.global.sandisk.com ([10.11.47.13]) by uls-op-cesaip02.wdc.com with ESMTP; 17 May 2018 13:38:25 -0700 From: adam.manzanares@wdc.com To: viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, axboe@kernel.dk, bcrl@kvack.org Cc: mingo@kernel.org, peterz@infradead.org, pombredanne@nexb.com, gregkh@linuxfoundation.org, bigeasy@linutronix.de, rgoldwyn@suse.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-aio@kvack.org, linux-api@vger.kernel.org, Adam Manzanares Subject: [PATCH v4 1/3] block: add ioprio_check_cap function Date: Thu, 17 May 2018 13:38:01 -0700 Message-Id: <20180517203803.2664-2-adam.manzanares@wdc.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180517203803.2664-1-adam.manzanares@wdc.com> References: <20180517203803.2664-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 --- 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