Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1887032imm; Tue, 22 May 2018 10:55:30 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpHJCbXFGRnqw9QDIKnIes9Gped/nQVKb1u4BzO0qDzddc2D9Ol4P5/IJLu0t98OFtmz79E X-Received: by 2002:a63:4202:: with SMTP id p2-v6mr19998557pga.137.1527011730716; Tue, 22 May 2018 10:55:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527011730; cv=none; d=google.com; s=arc-20160816; b=l8ZLG1nui28dnNtuL3O84FBQe1LFReNhCcSXIwx8GdP5WTWd0PIFd5wBR5wMOtcapN XhOQA7Cqk9WrHV3OtfrzYfDqF90fmBFUxPGyItJKF2tCYTfpejyKzNaI7G4dbUrR9eme Q/aIU3mN+w8kTCjyqnAeQlC92NsIn+x9HLCLa1XoczpH4CWo4nyiv20yH+RBtax2FB9c TpVRqonvfjPaQivsKyd7/v0hEKg6e1eo+WJiByVtUwqPJRT8VaSyOPLb6Cb9WZ8yUlup C4haAMmh44LjNqeYLRr/tLfCWi3ybHfqHF3YSuU7QhQZiqTISjYv6Bvi3jYWt9PyTwuN 1TYA== 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=KLzVs8ZcjGBR2iU1d3kiCulGx3UVcoC+9/iZcl63gRNjv45I5CSZEePCTT4K5q/TF/ 1Lv0s0KNFziwTblEXl0Z50ot4OuJ3M44bggq2LISosH8NsaWQ3HsQRNlNo37y++vmeG1 pJQE92tFNIbmK4kIexNwiAgI8JiT1LPMJeTyvLuDe1AHlB9QgnV8LRKIxegxf5xpJxFh sUzX9vXpf0ZTL5iu4iarhFR6E+pmFPbS+c/PSRGrx6SGk/ndVDc0aTHuUcAc4351/HkN ripd81bggfsyOEFi5VApGCmUvr3i/wtNbn3ysRULEuaXOBk22Wp7wtTemeCUuN1Blljm 7+wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=dhrFHJVp; 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 f13-v6si13419648pgp.168.2018.05.22.10.55.16; Tue, 22 May 2018 10:55:30 -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=dhrFHJVp; 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 S1752323AbeEVRwh (ORCPT + 99 others); Tue, 22 May 2018 13:52:37 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:22290 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751629AbeEVRwb (ORCPT ); Tue, 22 May 2018 13:52:31 -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=1527012188; x=1558548188; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=MMZnb089YcPmc7JQgRhiiLdezv9FOb/1CQLrwREj764=; b=dhrFHJVplk6l+a+vii5YuWnjYBp2VJsv8+KBTo7ZqMPwCH+49BAwc0B4 SrKXf2QQw+zL0l3VDGJEZTnqsaOvBjL+1Z7sl2Ce+RQ/FIsqJvc1+LO4x v/u0ljlzrUEWnFlxLboVzims9bg7ZgHRHhRTQcd+R9nHJM6a7NiaV2PAz Ii0tUiiRXUC7m5AXjSWdSLNijXQ458uJa0hLw+AmIbtsa8O1y4+RK7Dwl rX/pYAor536lpvi75TVzPSM9dyPbncpuKq/Tp34Tt1ELty7OdCMTvkULE ouxrpiBU+KJtq/j2qzvQbNQyRUVcZVgqb73K1+ieDVZ4IsgvcUNpzKTbv Q==; X-IronPort-AV: E=Sophos;i="5.49,430,1520870400"; d="scan'208";a="175448562" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 23 May 2018 02:03:07 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 22 May 2018 10:42:55 -0700 Received: from penguito-adamm.sdcorp.global.sandisk.com ([10.11.47.13]) by uls-op-cesaip02.wdc.com with ESMTP; 22 May 2018 10:52:31 -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, tglx@linutronix.de, kstewart@linuxfoundation.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, hch@infradread.org, jmoyer@redhat.com, Adam Manzanares Subject: [PATCH v7 1/5] block: add ioprio_check_cap function Date: Tue, 22 May 2018 10:52:17 -0700 Message-Id: <20180522175221.2391-2-adam.manzanares@wdc.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180522175221.2391-1-adam.manzanares@wdc.com> References: <20180522175221.2391-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