aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Slaby <jirislaby@gmail.com>2009-08-26 12:41:16 -0400
committerJiri Slaby <jirislaby@gmail.com>2010-07-16 03:48:45 -0400
commit8fd00b4d7014b00448eb33cf0590815304769798 (patch)
treef97cc5b4401dd038e539dae7ad66066383012866
parent2f7989efd4398d92b8adffce2e07dd043a0895fe (diff)
rlimits: security, add task_struct to setrlimit
Add task_struct to task_setrlimit of security_operations to be able to set rlimit of task other than current. Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Acked-by: Eric Paris <eparis@redhat.com> Acked-by: James Morris <jmorris@namei.org>
-rw-r--r--include/linux/security.h9
-rw-r--r--kernel/sys.c2
-rw-r--r--security/capability.c3
-rw-r--r--security/security.c5
-rw-r--r--security/selinux/hooks.c7
5 files changed, 16 insertions, 10 deletions
diff --git a/include/linux/security.h b/include/linux/security.h
index 0c8819170463..1a3eb5ff4357 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -1501,7 +1501,8 @@ struct security_operations {
1501 int (*task_setnice) (struct task_struct *p, int nice); 1501 int (*task_setnice) (struct task_struct *p, int nice);
1502 int (*task_setioprio) (struct task_struct *p, int ioprio); 1502 int (*task_setioprio) (struct task_struct *p, int ioprio);
1503 int (*task_getioprio) (struct task_struct *p); 1503 int (*task_getioprio) (struct task_struct *p);
1504 int (*task_setrlimit) (unsigned int resource, struct rlimit *new_rlim); 1504 int (*task_setrlimit) (struct task_struct *p, unsigned int resource,
1505 struct rlimit *new_rlim);
1505 int (*task_setscheduler) (struct task_struct *p, int policy, 1506 int (*task_setscheduler) (struct task_struct *p, int policy,
1506 struct sched_param *lp); 1507 struct sched_param *lp);
1507 int (*task_getscheduler) (struct task_struct *p); 1508 int (*task_getscheduler) (struct task_struct *p);
@@ -1751,7 +1752,8 @@ void security_task_getsecid(struct task_struct *p, u32 *secid);
1751int security_task_setnice(struct task_struct *p, int nice); 1752int security_task_setnice(struct task_struct *p, int nice);
1752int security_task_setioprio(struct task_struct *p, int ioprio); 1753int security_task_setioprio(struct task_struct *p, int ioprio);
1753int security_task_getioprio(struct task_struct *p); 1754int security_task_getioprio(struct task_struct *p);
1754int security_task_setrlimit(unsigned int resource, struct rlimit *new_rlim); 1755int security_task_setrlimit(struct task_struct *p, unsigned int resource,
1756 struct rlimit *new_rlim);
1755int security_task_setscheduler(struct task_struct *p, 1757int security_task_setscheduler(struct task_struct *p,
1756 int policy, struct sched_param *lp); 1758 int policy, struct sched_param *lp);
1757int security_task_getscheduler(struct task_struct *p); 1759int security_task_getscheduler(struct task_struct *p);
@@ -2313,7 +2315,8 @@ static inline int security_task_getioprio(struct task_struct *p)
2313 return 0; 2315 return 0;
2314} 2316}
2315 2317
2316static inline int security_task_setrlimit(unsigned int resource, 2318static inline int security_task_setrlimit(struct task_struct *p,
2319 unsigned int resource,
2317 struct rlimit *new_rlim) 2320 struct rlimit *new_rlim)
2318{ 2321{
2319 return 0; 2322 return 0;
diff --git a/kernel/sys.c b/kernel/sys.c
index e83ddbbaf89d..1ba4522689d4 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1290,7 +1290,7 @@ SYSCALL_DEFINE2(setrlimit, unsigned int, resource, struct rlimit __user *, rlim)
1290 if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open) 1290 if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open)
1291 return -EPERM; 1291 return -EPERM;
1292 1292
1293 retval = security_task_setrlimit(resource, &new_rlim); 1293 retval = security_task_setrlimit(current, resource, &new_rlim);
1294 if (retval) 1294 if (retval)
1295 return retval; 1295 return retval;
1296 1296
diff --git a/security/capability.c b/security/capability.c
index 8168e3ecd5bf..7e468263f2de 100644
--- a/security/capability.c
+++ b/security/capability.c
@@ -412,7 +412,8 @@ static int cap_task_getioprio(struct task_struct *p)
412 return 0; 412 return 0;
413} 413}
414 414
415static int cap_task_setrlimit(unsigned int resource, struct rlimit *new_rlim) 415static int cap_task_setrlimit(struct task_struct *p, unsigned int resource,
416 struct rlimit *new_rlim)
416{ 417{
417 return 0; 418 return 0;
418} 419}
diff --git a/security/security.c b/security/security.c
index 351942a4ca0e..aa510609a955 100644
--- a/security/security.c
+++ b/security/security.c
@@ -769,9 +769,10 @@ int security_task_getioprio(struct task_struct *p)
769 return security_ops->task_getioprio(p); 769 return security_ops->task_getioprio(p);
770} 770}
771 771
772int security_task_setrlimit(unsigned int resource, struct rlimit *new_rlim) 772int security_task_setrlimit(struct task_struct *p, unsigned int resource,
773 struct rlimit *new_rlim)
773{ 774{
774 return security_ops->task_setrlimit(resource, new_rlim); 775 return security_ops->task_setrlimit(p, resource, new_rlim);
775} 776}
776 777
777int security_task_setscheduler(struct task_struct *p, 778int security_task_setscheduler(struct task_struct *p,
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 5c9f25ba1c95..e3ce6b4127cc 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -3371,16 +3371,17 @@ static int selinux_task_getioprio(struct task_struct *p)
3371 return current_has_perm(p, PROCESS__GETSCHED); 3371 return current_has_perm(p, PROCESS__GETSCHED);
3372} 3372}
3373 3373
3374static int selinux_task_setrlimit(unsigned int resource, struct rlimit *new_rlim) 3374static int selinux_task_setrlimit(struct task_struct *p, unsigned int resource,
3375 struct rlimit *new_rlim)
3375{ 3376{
3376 struct rlimit *old_rlim = current->signal->rlim + resource; 3377 struct rlimit *old_rlim = p->signal->rlim + resource;
3377 3378
3378 /* Control the ability to change the hard limit (whether 3379 /* Control the ability to change the hard limit (whether
3379 lowering or raising it), so that the hard limit can 3380 lowering or raising it), so that the hard limit can
3380 later be used as a safe reset point for the soft limit 3381 later be used as a safe reset point for the soft limit
3381 upon context transitions. See selinux_bprm_committing_creds. */ 3382 upon context transitions. See selinux_bprm_committing_creds. */
3382 if (old_rlim->rlim_max != new_rlim->rlim_max) 3383 if (old_rlim->rlim_max != new_rlim->rlim_max)
3383 return current_has_perm(current, PROCESS__SETRLIMIT); 3384 return current_has_perm(p, PROCESS__SETRLIMIT);
3384 3385
3385 return 0; 3386 return 0;
3386} 3387}