diff options
author | James Morris <jmorris@namei.org> | 2006-06-23 05:03:58 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-23 10:42:53 -0400 |
commit | 03e68060636e05989ea94bcb671ab633948f328c (patch) | |
tree | aee5e7b55f31998536dd3a4f54f38caeee6105d6 /fs/ioprio.c | |
parent | 9216dfad4fc97ab639ef0885efc713f3d7a20d5b (diff) |
[PATCH] lsm: add task_setioprio hook
Implement an LSM hook for setting a task's IO priority, similar to the hook
for setting a tasks's nice value.
A previous version of this LSM hook was included in an older version of
multiadm by Jan Engelhardt, although I don't recall it being submitted
upstream.
Also included is the corresponding SELinux hook, which re-uses the setsched
permission in the proccess class.
Signed-off-by: James Morris <jmorris@namei.org>
Acked-by: Stephen Smalley <sds@tycho.nsa.gov>
Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
Cc: Chris Wright <chrisw@sous-sol.org>
Cc: Jens Axboe <axboe@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/ioprio.c')
-rw-r--r-- | fs/ioprio.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/ioprio.c b/fs/ioprio.c index ca77008146c0..7fa76ed53c10 100644 --- a/fs/ioprio.c +++ b/fs/ioprio.c | |||
@@ -24,15 +24,21 @@ | |||
24 | #include <linux/blkdev.h> | 24 | #include <linux/blkdev.h> |
25 | #include <linux/capability.h> | 25 | #include <linux/capability.h> |
26 | #include <linux/syscalls.h> | 26 | #include <linux/syscalls.h> |
27 | #include <linux/security.h> | ||
27 | 28 | ||
28 | static int set_task_ioprio(struct task_struct *task, int ioprio) | 29 | static int set_task_ioprio(struct task_struct *task, int ioprio) |
29 | { | 30 | { |
31 | int err; | ||
30 | struct io_context *ioc; | 32 | struct io_context *ioc; |
31 | 33 | ||
32 | if (task->uid != current->euid && | 34 | if (task->uid != current->euid && |
33 | task->uid != current->uid && !capable(CAP_SYS_NICE)) | 35 | task->uid != current->uid && !capable(CAP_SYS_NICE)) |
34 | return -EPERM; | 36 | return -EPERM; |
35 | 37 | ||
38 | err = security_task_setioprio(task, ioprio); | ||
39 | if (err) | ||
40 | return err; | ||
41 | |||
36 | task_lock(task); | 42 | task_lock(task); |
37 | 43 | ||
38 | task->ioprio = ioprio; | 44 | task->ioprio = ioprio; |