mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiri Slaby <jslaby@suse.cz>
To: jirislaby@gmail.com
Cc: mingo@elte.hu, nhorman@tuxdriver.com, sfr@canb.auug.org.au,
	linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	marcin.slusarz@gmail.com, tglx@linutronix.de, mingo@redhat.com,
	hpa@zytor.com, torvalds@linux-foundation.org, oleg@redhat.com
Subject: [PATCH v3 02/27] SECURITY: add task_struct to setrlimit
Date: Sat, 28 Nov 2009 00:05:42 +0100	[thread overview]
Message-ID: <1259363167-9347-2-git-send-email-jslaby@suse.cz> (raw)
In-Reply-To: <1259363167-9347-1-git-send-email-jslaby@suse.cz>

From: Jiri Slaby <jirislaby@gmail.com>

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 <jirislaby@gmail.com>
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(-)

diff --git a/include/linux/security.h b/include/linux/security.h
index 239e40d..193b3d9 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -1570,7 +1570,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);
@@ -1835,7 +1836,8 @@ int security_task_setgroups(struct group_info *group_info);
 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);
@@ -2451,7 +2453,8 @@ static inline int security_task_getioprio(struct task_struct *p)
 	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;
diff --git a/kernel/sys.c b/kernel/sys.c
index ce17760..9898a8a 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1256,7 +1256,7 @@ SYSCALL_DEFINE2(setrlimit, unsigned int, resource, struct rlimit __user *, rlim)
 	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;
 
diff --git a/security/capability.c b/security/capability.c
index fce07a7..5882ec0 100644
--- a/security/capability.c
+++ b/security/capability.c
@@ -450,7 +450,8 @@ static int cap_task_getioprio(struct task_struct *p)
 	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;
 }
diff --git a/security/security.c b/security/security.c
index c4c6732..4b23d83 100644
--- a/security/security.c
+++ b/security/security.c
@@ -781,9 +781,10 @@ int security_task_getioprio(struct task_struct *p)
 	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,
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 36d9e25..1167f01 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -3390,16 +3390,17 @@ static int selinux_task_getioprio(struct task_struct *p)
 	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;
 }
-- 
1.6.5.3


  reply	other threads:[~2009-11-27 23:06 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-27 23:05 [PATCH v3 01/27] SECURITY: selinux, fix update_rlimit_cpu parameter Jiri Slaby
2009-11-27 23:05 ` Jiri Slaby [this message]
2009-11-27 23:05 ` [PATCH v3 03/27] core: add task_struct to update_rlimit_cpu Jiri Slaby
2009-11-27 23:05 ` [PATCH v3 04/27] sys_setrlimit: make sure ->rlim_max never grows Jiri Slaby
2009-11-27 23:05 ` [PATCH v3 05/27] core: split sys_setrlimit Jiri Slaby
2009-11-27 23:05 ` [PATCH v3 06/27] core: allow setrlimit to non-current tasks Jiri Slaby
2009-11-27 23:05 ` [PATCH v3 07/27] core: optimize setrlimit for current task Jiri Slaby
2009-11-27 23:05 ` [PATCH v3 08/27] FS: proc, switch limits reading to fops Jiri Slaby
2009-11-27 23:05 ` [PATCH v3 09/27] FS: proc, make limits writable Jiri Slaby
2009-11-27 23:05 ` [PATCH v3 10/27] core: do security check under task_lock Jiri Slaby
2009-11-27 23:05 ` [PATCH v3 11/27] core: rename setrlimit to do_setrlimit Jiri Slaby
2009-11-27 23:05 ` [PATCH v3 12/27] resource: move kernel functions inside __KERNEL__ Jiri Slaby
2009-11-27 23:05 ` [PATCH v3 13/27] core: posix-cpu-timers, cleanup rlimits usage Jiri Slaby
2009-11-27 23:05 ` [PATCH v3 14/27] resource: add helpers for fetching rlimits Jiri Slaby
2009-11-27 23:05 ` [PATCH v3 15/27] IA64: use helpers for rlimits Jiri Slaby
2009-11-27 23:05 ` [PATCH v3 16/27] PPC: " Jiri Slaby
2009-11-28  0:19   ` Benjamin Herrenschmidt
2009-11-28  8:47     ` Jiri Slaby
2009-11-28 21:16       ` Benjamin Herrenschmidt
2009-11-29 11:06         ` Stephen Rothwell
2009-11-27 23:05 ` [PATCH v3 17/27] S390: " Jiri Slaby
2009-11-27 23:05 ` [PATCH v3 18/27] SPARC: " Jiri Slaby
2009-11-27 23:05 ` [PATCH v3 19/27] X86: " Jiri Slaby
2009-11-27 23:06 ` [PATCH v3 20/27] FS: " Jiri Slaby
2009-11-27 23:06 ` [PATCH v3 21/27] MM: " Jiri Slaby
2009-11-27 23:06 ` [PATCH v3 22/27] core: " Jiri Slaby
2009-11-27 23:06 ` [PATCH v3 23/27] misc: " Jiri Slaby
2009-12-09 23:59   ` Roland Dreier
2009-11-27 23:06 ` [PATCH v3 24/27] core: implement getprlimit and setprlimit syscalls Jiri Slaby
2009-11-27 23:06 ` [PATCH v3 25/27] unistd: add __NR_[get|set]prlimit syscall numbers Jiri Slaby
2009-11-27 23:06 ` [PATCH v3 26/27] COMPAT: add get/put_compat_rlimit Jiri Slaby
2009-11-27 23:06 ` [PATCH v3 27/27] x86: add ia32 compat prlimit syscalls Jiri Slaby
2009-11-27 23:41 ` [PATCH v3 00/27] writable limits Jiri Slaby
2009-11-28  7:28   ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1259363167-9347-2-git-send-email-jslaby@suse.cz \
    --to=jslaby@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=hpa@zytor.com \
    --cc=jirislaby@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcin.slusarz@gmail.com \
    --cc=mingo@elte.hu \
    --cc=mingo@redhat.com \
    --cc=nhorman@tuxdriver.com \
    --cc=oleg@redhat.com \
    --cc=sfr@canb.auug.org.au \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®