diff options
author | Adam Manzanares <adam.manzanares@wdc.com> | 2018-05-22 13:52:17 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2018-05-31 10:50:54 -0400 |
commit | aa43457799f715d76cb77342baab0615877e2b8a (patch) | |
tree | df9115b36ef602d0550e9c2626b5c53a705425ac | |
parent | 1da92779e2e8f309d5aecbbed346e7f812b174e8 (diff) |
block: add ioprio_check_cap function
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>
-rw-r--r-- | block/ioprio.c | 22 | ||||
-rw-r--r-- | 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) | |||
61 | } | 61 | } |
62 | EXPORT_SYMBOL_GPL(set_task_ioprio); | 62 | EXPORT_SYMBOL_GPL(set_task_ioprio); |
63 | 63 | ||
64 | SYSCALL_DEFINE3(ioprio_set, int, which, int, who, int, ioprio) | 64 | int ioprio_check_cap(int ioprio) |
65 | { | 65 | { |
66 | int class = IOPRIO_PRIO_CLASS(ioprio); | 66 | int class = IOPRIO_PRIO_CLASS(ioprio); |
67 | int data = IOPRIO_PRIO_DATA(ioprio); | 67 | int data = IOPRIO_PRIO_DATA(ioprio); |
68 | struct task_struct *p, *g; | ||
69 | struct user_struct *user; | ||
70 | struct pid *pgrp; | ||
71 | kuid_t uid; | ||
72 | int ret; | ||
73 | 68 | ||
74 | switch (class) { | 69 | switch (class) { |
75 | case IOPRIO_CLASS_RT: | 70 | case IOPRIO_CLASS_RT: |
@@ -92,6 +87,21 @@ SYSCALL_DEFINE3(ioprio_set, int, which, int, who, int, ioprio) | |||
92 | return -EINVAL; | 87 | return -EINVAL; |
93 | } | 88 | } |
94 | 89 | ||
90 | return 0; | ||
91 | } | ||
92 | |||
93 | SYSCALL_DEFINE3(ioprio_set, int, which, int, who, int, ioprio) | ||
94 | { | ||
95 | struct task_struct *p, *g; | ||
96 | struct user_struct *user; | ||
97 | struct pid *pgrp; | ||
98 | kuid_t uid; | ||
99 | int ret; | ||
100 | |||
101 | ret = ioprio_check_cap(ioprio); | ||
102 | if (ret) | ||
103 | return ret; | ||
104 | |||
95 | ret = -ESRCH; | 105 | ret = -ESRCH; |
96 | rcu_read_lock(); | 106 | rcu_read_lock(); |
97 | switch (which) { | 107 | 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); | |||
77 | 77 | ||
78 | extern int set_task_ioprio(struct task_struct *task, int ioprio); | 78 | extern int set_task_ioprio(struct task_struct *task, int ioprio); |
79 | 79 | ||
80 | extern int ioprio_check_cap(int ioprio); | ||
81 | |||
80 | #endif | 82 | #endif |