115 lines
4.2 KiB
Diff
115 lines
4.2 KiB
Diff
|
From 9440a3f562ffe6ab34eff1ab52e6cfc516d6e7ba Mon Sep 17 00:00:00 2001
|
||
|
From: Jiri Slaby <jirislaby@gmail.com>
|
||
|
Date: Wed, 26 Aug 2009 18:41:16 +0200
|
||
|
Subject: [PATCH] SECURITY: add task_struct to setrlimit
|
||
|
References: FATE#305733
|
||
|
Patch-mainline: no (later)
|
||
|
|
||
|
Add task_struct to task_setrlimit of security_operations to be able to set
|
||
|
rlimit of different task than current.
|
||
|
|
||
|
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
|
||
|
Acked-by: Eric Paris <eparis@redhat.com>
|
||
|
Acked-by: James Morris <jmorris@namei.org>
|
||
|
---
|
||
|
include/linux/security.h | 9 ++++++---
|
||
|
kernel/sys.c | 2 +-
|
||
|
security/capability.c | 3 ++-
|
||
|
security/security.c | 5 +++--
|
||
|
security/selinux/hooks.c | 7 ++++---
|
||
|
5 files changed, 16 insertions(+), 10 deletions(-)
|
||
|
|
||
|
--- a/include/linux/security.h
|
||
|
+++ b/include/linux/security.h
|
||
|
@@ -1602,7 +1602,8 @@ struct security_operations {
|
||
|
int (*task_setnice) (struct task_struct *p, int nice);
|
||
|
int (*task_setioprio) (struct task_struct *p, int ioprio);
|
||
|
int (*task_getioprio) (struct task_struct *p);
|
||
|
- int (*task_setrlimit) (unsigned int resource, struct rlimit *new_rlim);
|
||
|
+ int (*task_setrlimit) (struct task_struct *p, unsigned int resource,
|
||
|
+ struct rlimit *new_rlim);
|
||
|
int (*task_setscheduler) (struct task_struct *p, int policy,
|
||
|
struct sched_param *lp);
|
||
|
int (*task_getscheduler) (struct task_struct *p);
|
||
|
@@ -1867,7 +1868,8 @@ int security_task_setgroups(struct group
|
||
|
int security_task_setnice(struct task_struct *p, int nice);
|
||
|
int security_task_setioprio(struct task_struct *p, int ioprio);
|
||
|
int security_task_getioprio(struct task_struct *p);
|
||
|
-int security_task_setrlimit(unsigned int resource, struct rlimit *new_rlim);
|
||
|
+int security_task_setrlimit(struct task_struct *p, unsigned int resource,
|
||
|
+ struct rlimit *new_rlim);
|
||
|
int security_task_setscheduler(struct task_struct *p,
|
||
|
int policy, struct sched_param *lp);
|
||
|
int security_task_getscheduler(struct task_struct *p);
|
||
|
@@ -2483,7 +2485,8 @@ static inline int security_task_getiopri
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
-static inline int security_task_setrlimit(unsigned int resource,
|
||
|
+static inline int security_task_setrlimit(struct task_struct *p,
|
||
|
+ unsigned int resource,
|
||
|
struct rlimit *new_rlim)
|
||
|
{
|
||
|
return 0;
|
||
|
--- a/kernel/sys.c
|
||
|
+++ b/kernel/sys.c
|
||
|
@@ -1320,7 +1320,7 @@ SYSCALL_DEFINE2(setrlimit, unsigned int,
|
||
|
if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open)
|
||
|
return -EPERM;
|
||
|
|
||
|
- retval = security_task_setrlimit(resource, &new_rlim);
|
||
|
+ retval = security_task_setrlimit(current, resource, &new_rlim);
|
||
|
if (retval)
|
||
|
return retval;
|
||
|
|
||
|
--- a/security/capability.c
|
||
|
+++ b/security/capability.c
|
||
|
@@ -466,7 +466,8 @@ static int cap_task_getioprio(struct tas
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
-static int cap_task_setrlimit(unsigned int resource, struct rlimit *new_rlim)
|
||
|
+static int cap_task_setrlimit(struct task_struct *p, unsigned int resource,
|
||
|
+ struct rlimit *new_rlim)
|
||
|
{
|
||
|
return 0;
|
||
|
}
|
||
|
--- a/security/security.c
|
||
|
+++ b/security/security.c
|
||
|
@@ -832,9 +832,10 @@ int security_task_getioprio(struct task_
|
||
|
return security_ops->task_getioprio(p);
|
||
|
}
|
||
|
|
||
|
-int security_task_setrlimit(unsigned int resource, struct rlimit *new_rlim)
|
||
|
+int security_task_setrlimit(struct task_struct *p, unsigned int resource,
|
||
|
+ struct rlimit *new_rlim)
|
||
|
{
|
||
|
- return security_ops->task_setrlimit(resource, new_rlim);
|
||
|
+ return security_ops->task_setrlimit(p, resource, new_rlim);
|
||
|
}
|
||
|
|
||
|
int security_task_setscheduler(struct task_struct *p,
|
||
|
--- a/security/selinux/hooks.c
|
||
|
+++ b/security/selinux/hooks.c
|
||
|
@@ -3393,16 +3393,17 @@ static int selinux_task_getioprio(struct
|
||
|
return current_has_perm(p, PROCESS__GETSCHED);
|
||
|
}
|
||
|
|
||
|
-static int selinux_task_setrlimit(unsigned int resource, struct rlimit *new_rlim)
|
||
|
+static int selinux_task_setrlimit(struct task_struct *p, unsigned int resource,
|
||
|
+ struct rlimit *new_rlim)
|
||
|
{
|
||
|
- struct rlimit *old_rlim = current->signal->rlim + resource;
|
||
|
+ struct rlimit *old_rlim = p->signal->rlim + resource;
|
||
|
|
||
|
/* Control the ability to change the hard limit (whether
|
||
|
lowering or raising it), so that the hard limit can
|
||
|
later be used as a safe reset point for the soft limit
|
||
|
upon context transitions. See selinux_bprm_committing_creds. */
|
||
|
if (old_rlim->rlim_max != new_rlim->rlim_max)
|
||
|
- return current_has_perm(current, PROCESS__SETRLIMIT);
|
||
|
+ return current_has_perm(p, PROCESS__SETRLIMIT);
|
||
|
|
||
|
return 0;
|
||
|
}
|