Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp762915imm; Mon, 21 May 2018 14:00:04 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrUE/1+mQAsGwx3fZxQKMtN0aNcgVtgbjQMvm5DCVf/1YjvSq4WJZ1gwOiEsc63s7VYMT9Z X-Received: by 2002:a65:4b49:: with SMTP id k9-v6mr16668535pgt.369.1526936404892; Mon, 21 May 2018 14:00:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526936404; cv=none; d=google.com; s=arc-20160816; b=SpmmInFngyc5aSTXZhH9pDIRDpYaZlok/kyJisHf7cCXvcDlnmH+i7yLD0BaXGNPFQ KtmDimaFSFjzKBMWmQ0vWTL7nA4SzHGFjF5nupgfaeMkR5SG5ugWCW/VXLsBGxQZDI4j VSzFkxVP/zeX4RbwZSe6e3RdoLncuUrdXYfJ2DZhT2ZCOxG6lSQ2Jq7+dLA4CHOsNpVJ /foKWNaaxyOO686nAWWn4RsExArFDR5L63OL45NuukbubNM2lNyXWcVM+YqjTa5Y7GQW v0/BTEyxiiJRFP8/Li4BSUYfPmyd4GTOUDa9uqSSXevT1I10d/TzJNvDmvL6UGWxll8W 0YZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:user-agent :references:in-reply-to:subject:cc:to:from :arc-authentication-results; bh=HNGzkLY8/1NVKEnBhNHn8TgCNxocy4g74qu6xTIq670=; b=djwaj5raCBlRFTAXCZpPGrOuY/ybADv7gDcvLBpx1vAZlBO88m1kHRCR+zI+o3SLvx UPUX5IJd7kRWNopSlYtMoSKea/F5esxj1BEpdPs68/1GyVrcfNjCGBQyEwwahs669k9j ST6Jj7qB+shnOiOlHiUSoWiDtOWyMr39VJMkOvl+7Jm8w59vT0Fdrfbm6oJYKm8h4GzL cLxo6ru2ZNuPyfXW5T0BcFVgSxP9s4xwvRtlGPKDSp7nLaD9TyUFfkGCAo4yEAHBW67A 6YLEmaTK6lyGTWD9onObmCexEjUBXS00DNSFPWWH80OO2aO9uhsiSSAeG/BMkmUB/FFS mZnw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p8-v6si11629200pgs.441.2018.05.21.13.59.50; Mon, 21 May 2018 14:00:04 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751858AbeEUU6U (ORCPT + 99 others); Mon, 21 May 2018 16:58:20 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44084 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751746AbeEUU6R (ORCPT ); Mon, 21 May 2018 16:58:17 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 465CC7D83F; Mon, 21 May 2018 20:58:16 +0000 (UTC) Received: from segfault.boston.devel.redhat.com (segfault.boston.devel.redhat.com [10.19.60.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5489B2026DEF; Mon, 21 May 2018 20:58:15 +0000 (UTC) From: Jeff Moyer To: adam.manzanares@wdc.com Cc: viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, axboe@kernel.dk, bcrl@kvack.org, 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@infradead.org Subject: Re: [PATCH v5 1/5] block: add ioprio_check_cap function In-Reply-To: <20180521160147.2372-2-adam.manzanares@wdc.com> (adam manzanares's message of "Mon, 21 May 2018 09:01:43 -0700") References: <20180521160147.2372-1-adam.manzanares@wdc.com> <20180521160147.2372-2-adam.manzanares@wdc.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-PGP-KeyID: 1F78E1B4 X-PGP-CertKey: F6FE 280D 8293 F72C 65FD 5A58 1FF8 A7CA 1F78 E1B4 X-PCLoadLetter: What the f**k does that mean? Date: Mon, 21 May 2018 16:58:14 -0400 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 21 May 2018 20:58:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 21 May 2018 20:58:16 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jmoyer@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org adam.manzanares@wdc.com writes: > 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 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