Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1709412imm; Tue, 22 May 2018 08:10:09 -0700 (PDT) X-Google-Smtp-Source: AB8JxZowJWfHcMK6J8bWxf/WQOkcbMn3IqO0itY8Hs1/wPWribjxHIhBMwsGebf9jyaNTV6hZa7z X-Received: by 2002:a62:4184:: with SMTP id g4-v6mr24710289pfd.51.1527001809320; Tue, 22 May 2018 08:10:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527001809; cv=none; d=google.com; s=arc-20160816; b=PiDc69m6WPokGcsaGqFeaPYNnNVnwYqtDY/1DUljq2r7kAJB+1sw6W9RJ3TJDvek/U 32yYxWycPFayDrSljgszTtOc/rQ1G7nQf0QvXrViBIUSwGHx2lkyKZveZyFi3AvVgHfl SNZgHGJQRbUoAj20/PkKowj30Wd+WeF0CDX7MwOFzx1m3pR0/wbcOVL5V8jTyijUsOOV SXrNgON2A0H60Y8rhxw/tb2mPQxgpURXi+mxf4hY+OPCxBiDasp45YpC9gMYSG8vetKe 61WaESDQ0DUI1YKxx/HHE2S0n0fJz6szEqg61/H13kr2WzsLrWaULVqzQgbk0LTAqpTE p59Q== 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=v4GJdK5PrcXBJ5eA6PXEhukTQ4kXyoWkkoBftrIK8dk=; b=RfhhS9DfmtP7yLmMzq0BAvKlwiteOsIIN42jbBF/kt3QwreTmhZL++6b/BgnZ6hVhz d0Eo3B2t+Ou3qSazFLg5K5toRtXyn7ANihliZQKBEqHCJYHzFvyfNEN0lSkLuz/sfOQt ZGrbZgYkcCbRUMuOkTjzDd3p+e6oWQRnivf2Q7RgqHrD1wGtagHGiFiyKg3ODYCCeelD bwuN1Kd+/e1UE8j4aefsMqYkSfYDLZXIohPu+AleV26AOs89TPbrd4B/y3OvBwoADYH9 GZAEoHZmwd5TixN+T5jtXDSOPY4GGib+o/++6BXHL1UL7TRgwCUZddHzOJr4E5rvKKFw Kw5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=nhBYGwNw; 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 22-v6si10188535pgh.407.2018.05.22.08.09.38; Tue, 22 May 2018 08:10:09 -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=nhBYGwNw; 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 S1752199AbeEVPH5 (ORCPT + 99 others); Tue, 22 May 2018 11:07:57 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:26472 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751842AbeEVPHy (ORCPT ); Tue, 22 May 2018 11:07:54 -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=1527001675; x=1558537675; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=MMZnb089YcPmc7JQgRhiiLdezv9FOb/1CQLrwREj764=; b=nhBYGwNwvu6jCBnTQeFgLxJoc1Y5+xc5QAM+yi5NssLmRPWYDcD0kL8z NwT8P+iQW2k7GyP7ZXx6mmctwYcsTfwIYXx194eY+nNmvFNihwWBWngKI SiL3IpGqgjqdfg3YKzcAHwner/jNIqajESGcbOaNK+G9WM5HpV1+aEbe5 O/L8AFUWHmD2AFa97sk78fILng2EYA9eIXLbfb6lOAYKVfxHVreA7zWEJ zr715PhlRGMfSG6MkMZRTxDH56QUdK7fNZnGYodxSae5SEQAyJHEF5mgu eXjtXkhR25S9zpC2HupkfMPY9vwDKO/kjsXGumS1fvCzEkC3ntkJaOyve A==; X-IronPort-AV: E=Sophos;i="5.49,430,1520870400"; d="scan'208";a="79548762" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 22 May 2018 23:07:54 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 22 May 2018 07:58:49 -0700 Received: from penguito-adamm.sdcorp.global.sandisk.com ([10.11.47.13]) by uls-op-cesaip02.wdc.com with ESMTP; 22 May 2018 08:07:54 -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, jmoyer@redhat.com, Adam Manzanares Subject: [PATCH v6 1/5] block: add ioprio_check_cap function Date: Tue, 22 May 2018 08:07:33 -0700 Message-Id: <20180522150737.9893-2-adam.manzanares@wdc.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180522150737.9893-1-adam.manzanares@wdc.com> References: <20180522150737.9893-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 privileges 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 Reviewed-by: Jeff Moyer --- 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