Skip to content

Commit

Permalink
block: add ioprio_check_cap function
Browse files Browse the repository at this point in the history
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 <adam.manzanares@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
nmtadam authored and Al Viro committed May 31, 2018
1 parent 1da9277 commit aa43457
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
22 changes: 16 additions & 6 deletions block/ioprio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions include/linux/ioprio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit aa43457

Please sign in to comment.