Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 28955
b: refs/heads/master
c: 03e6806
h: refs/heads/master
i:
  28953: 9ffe17f
  28951: 312cc2f
v: v3
  • Loading branch information
James Morris authored and Linus Torvalds committed Jun 23, 2006
1 parent c97a902 commit 6bf30db
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9216dfad4fc97ab639ef0885efc713f3d7a20d5b
refs/heads/master: 03e68060636e05989ea94bcb671ab633948f328c
6 changes: 6 additions & 0 deletions trunk/fs/ioprio.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,21 @@
#include <linux/blkdev.h>
#include <linux/capability.h>
#include <linux/syscalls.h>
#include <linux/security.h>

static int set_task_ioprio(struct task_struct *task, int ioprio)
{
int err;
struct io_context *ioc;

if (task->uid != current->euid &&
task->uid != current->uid && !capable(CAP_SYS_NICE))
return -EPERM;

err = security_task_setioprio(task, ioprio);
if (err)
return err;

task_lock(task);

task->ioprio = ioprio;
Expand Down
16 changes: 16 additions & 0 deletions trunk/include/linux/security.h
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,11 @@ struct swap_info_struct;
* @p contains the task_struct of process.
* @nice contains the new nice value.
* Return 0 if permission is granted.
* @task_setioprio
* Check permission before setting the ioprio value of @p to @ioprio.
* @p contains the task_struct of process.
* @ioprio contains the new ioprio value
* Return 0 if permission is granted.
* @task_setrlimit:
* Check permission before setting the resource limits of the current
* process for @resource to @new_rlim. The old resource limit values can
Expand Down Expand Up @@ -1210,6 +1215,7 @@ struct security_operations {
int (*task_getsid) (struct task_struct * p);
int (*task_setgroups) (struct group_info *group_info);
int (*task_setnice) (struct task_struct * p, int nice);
int (*task_setioprio) (struct task_struct * p, int ioprio);
int (*task_setrlimit) (unsigned int resource, struct rlimit * new_rlim);
int (*task_setscheduler) (struct task_struct * p, int policy,
struct sched_param * lp);
Expand Down Expand Up @@ -1836,6 +1842,11 @@ static inline int security_task_setnice (struct task_struct *p, int nice)
return security_ops->task_setnice (p, nice);
}

static inline int security_task_setioprio (struct task_struct *p, int ioprio)
{
return security_ops->task_setioprio (p, ioprio);
}

static inline int security_task_setrlimit (unsigned int resource,
struct rlimit *new_rlim)
{
Expand Down Expand Up @@ -2478,6 +2489,11 @@ static inline int security_task_setnice (struct task_struct *p, int nice)
return 0;
}

static inline int security_task_setioprio (struct task_struct *p, int ioprio)
{
return 0;
}

static inline int security_task_setrlimit (unsigned int resource,
struct rlimit *new_rlim)
{
Expand Down
6 changes: 6 additions & 0 deletions trunk/security/dummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,11 @@ static int dummy_task_setnice (struct task_struct *p, int nice)
return 0;
}

static int dummy_task_setioprio (struct task_struct *p, int ioprio)
{
return 0;
}

static int dummy_task_setrlimit (unsigned int resource, struct rlimit *new_rlim)
{
return 0;
Expand Down Expand Up @@ -972,6 +977,7 @@ void security_fixup_ops (struct security_operations *ops)
set_to_dummy_if_null(ops, task_getsid);
set_to_dummy_if_null(ops, task_setgroups);
set_to_dummy_if_null(ops, task_setnice);
set_to_dummy_if_null(ops, task_setioprio);
set_to_dummy_if_null(ops, task_setrlimit);
set_to_dummy_if_null(ops, task_setscheduler);
set_to_dummy_if_null(ops, task_getscheduler);
Expand Down
6 changes: 6 additions & 0 deletions trunk/security/selinux/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -2645,6 +2645,11 @@ static int selinux_task_setnice(struct task_struct *p, int nice)
return task_has_perm(current,p, PROCESS__SETSCHED);
}

static int selinux_task_setioprio(struct task_struct *p, int ioprio)
{
return task_has_perm(current, p, PROCESS__SETSCHED);
}

static int selinux_task_setrlimit(unsigned int resource, struct rlimit *new_rlim)
{
struct rlimit *old_rlim = current->signal->rlim + resource;
Expand Down Expand Up @@ -4383,6 +4388,7 @@ static struct security_operations selinux_ops = {
.task_getsid = selinux_task_getsid,
.task_setgroups = selinux_task_setgroups,
.task_setnice = selinux_task_setnice,
.task_setioprio = selinux_task_setioprio,
.task_setrlimit = selinux_task_setrlimit,
.task_setscheduler = selinux_task_setscheduler,
.task_getscheduler = selinux_task_getscheduler,
Expand Down

0 comments on commit 6bf30db

Please sign in to comment.