Received: by 10.192.165.148 with SMTP id m20csp4584675imm; Tue, 8 May 2018 10:43:22 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq075PBM6iEkwV2OaDy6oLqHsSkVFzrw6uI4IxViTsHw/lx1maF4+g0GjugpxqIS5gNOsih X-Received: by 2002:a17:902:aa04:: with SMTP id be4-v6mr42431710plb.20.1525801402386; Tue, 08 May 2018 10:43:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525801402; cv=none; d=google.com; s=arc-20160816; b=U9MPjwQq5BCrzk+PwryAyOdDv6O8HIMcfdhJAeb7fQYqivTmVMvnE3j5ftb7EbgTx6 vzRQdNNdC5H2AkPtF4GCbSi8CVOr6dWMhQ/EcAsi1flDdBhXtE942r7tb4Fb8+L+5uy2 N5EC4bMPPNFzekVxzaqCysrh4/gNumRriyBKrRO50U+tkjQ5U8U2KOD+eWXaok288Rcc tS05fLwDNMtSHaqZhg1yaKdOM9CC+qVG/+CEV6drsrHja3Q79DiqSmNQ+Wx1Nxlau14/ 1Dswe/v1EufbJlKmGagCsQGyRTW6TkEp7ZpURes0tn7zlONoB/GtCwtD7q1IK/DyyyPT UkAA== 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=nsPkzO5Grv9uFrdRA2diPJlTyK/0qcaqHstqAoGZnZoRjVJyUszAa5UADJXL23WrXS xaLA+Aa4jqqEHMBSTYjmglFTtO3n2f4u5KmhwxU+jr0j3C8CsL8IkUP4Nxnrqkv1EdFf 2n/WG94zduWWEi8iYUwiJD0m3Kbg0uufFMGojuH4pAFev39iFXlGqqjFzJmgWN3T5K9J wdIwuC9okOVmGuP8GyKd6elB6ssIIINpA+EbAjj6WOvGy5vb8Bp+H/bgG9c64CD/KmQS w0daz292jtZeqDS8qOv3o0tHagLRox8DTFi1U8f/1NgJWVtLzYlspNFXh79t/PI8YMg5 tY7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=R/2bLjpy; 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 bc2-v6si3260239plb.43.2018.05.08.10.43.07; Tue, 08 May 2018 10:43:22 -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=R/2bLjpy; 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 S1755451AbeEHRmj (ORCPT + 99 others); Tue, 8 May 2018 13:42:39 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:39537 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752239AbeEHRmf (ORCPT ); Tue, 8 May 2018 13:42:35 -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=1525801355; x=1557337355; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=VhkY9dahP0w7hX8nSZ/ahhZiwEaZo6BRX/KgMDBwoEg=; b=R/2bLjpycc7ld6/xCZqYrqdeZoOE/xfve9hjkMo+UDW4VRHqVmlJNTX3 cSPShFwXaSKxBt2CDbcycEk4Cec8ex4zBZwYYAUoi7pU6/4kR6zXxuz2s rPJehsrgr44P60BWU9Us7W7SK25Mny0wjiKEjOURnrphqjVrKA3wdkrYi Wzd32VISrjyrjsdw41fI5IiamR90stVD+nmIvcwA8NEX3a++kwVtaY0il QdwAf8nJbdKOdfUgARGsY8/DSDKejdsaFyPy4qvnu8Wl8DwVjTlGAS+06 ejnwfsx3d/9ctBbBxByP/JgAwOt+hMBwclVjz7vmHNUpj2s17LUUHf9Q3 w==; X-IronPort-AV: E=Sophos;i="5.49,379,1520870400"; d="scan'208";a="180732631" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 09 May 2018 01:42:34 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 08 May 2018 10:34:15 -0700 Received: from penguito-adamm.sdcorp.global.sandisk.com ([10.11.47.13]) by uls-op-cesaip02.wdc.com with ESMTP; 08 May 2018 10:42:35 -0700 From: adam.manzanares@wdc.com To: viro@zeniv.linux.org.uk, bcrl@kvack.org Cc: linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, linux-api@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Adam Manzanares Subject: [PATCH v3 1/3] block: add ioprio_check_cap function Date: Tue, 8 May 2018 10:42:00 -0700 Message-Id: <20180508174202.2537-2-adam.manzanares@wdc.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180508174202.2537-1-adam.manzanares@wdc.com> References: <20180508174202.2537-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