mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Add security_task_post_setgid
@ 2005-07-14 21:42 Jan Engelhardt
  2005-07-14 22:38 ` Christoph Hellwig
  2005-07-14 23:14 ` [PATCH] " Chris Wright
  0 siblings, 2 replies; 7+ messages in thread
From: Jan Engelhardt @ 2005-07-14 21:42 UTC (permalink / raw)
  To: Linux Kernel Mailing List

Hi,


the following patch adds a post_setgid() security hook, and necessary dummy 
funcs.

Signed-off-by: Jan Engelhardt <jengelh@linux01.gwdg.de>

diff -dpru linux-2.6.13-rc1-git3-20050706140055/include/linux/security.h AS17/include/linux/security.h
--- linux-2.6.13-rc1-git3-20050706140055/include/linux/security.h	2005-07-11 22:16:30.000000000 +0200
+++ AS17/include/linux/security.h	2005-07-14 23:28:45.000000000 +0200
@@ -558,6 +558,17 @@ struct swap_info_struct;
  *	@id2 contains a gid.
  *	@flags contains one of the LSM_SETID_* values.
  *	Return 0 if permission is granted.
+ * @task_post_setgid:
+ *	Update the module's state after setting one or more of the user
+ *	identity attributes of the current process. The @flags parameter
+ *	indicates which of the set*gid system calls invoked this hook. If
+ *	@flags is LSM_SETID_FS, then @old_rgid is the old fs gid and the other
+ *	parameters are not used.
+ *	@old_rgid contains the old real gid (or fs gid if LSM_SETID_FS).
+ *	@old_egid contains the old effective gid (or -1 if LSM_SETID_FS).
+ *	@old_sgid contains the old saved gid (or -1 if LSM_SETID_FS).
+ *	@flags contains one of the LSM_SETID_* values.
+ *	Return 0 on success.
  * @task_setpgid:
  *	Check permission before setting the process group identifier of the
  *	process @p to @pgid.
@@ -1151,6 +1162,7 @@ struct security_operations {
 	int (*task_post_setuid) (uid_t old_ruid /* or fsuid */ ,
 				 uid_t old_euid, uid_t old_suid, int flags);
 	int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags);
+	int (*task_post_setgid) (gid_t, gid_t, gid_t, int);
 	int (*task_setpgid) (struct task_struct * p, pid_t pgid);
 	int (*task_getpgid) (struct task_struct * p);
 	int (*task_getsid) (struct task_struct * p);
@@ -1949,6 +1961,12 @@ static inline int security_task_setgid (
 			 0);
 }
 
+static inline int security_task_post_setgid(gid_t id0, gid_t id1, gid_t id2,
+					int flags)
+{
+	return COND_SECURITY(task_post_setgid(id0, id1, id2, flags), 0);
+}
+
 static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
 {
 	return COND_SECURITY(task_setpgid (p, pgid),
diff -dpru linux-2.6.13-rc1-git3-20050706140055/kernel/sys.c AS17/kernel/sys.c
--- linux-2.6.13-rc1-git3-20050706140055/kernel/sys.c	2005-07-07 20:53:44.000000000 +0200
+++ AS17/kernel/sys.c	2005-07-14 23:23:12.000000000 +0200
@@ -558,7 +558,7 @@ asmlinkage long sys_setregid(gid_t rgid,
 	current->egid = new_egid;
 	current->gid = new_rgid;
 	key_fsgid_changed(current);
-	return 0;
+	return security_task_post_setgid(old_rgid, old_egid, -1, LSM_SETID_RE);
 }
 
 /*
@@ -597,7 +597,7 @@ asmlinkage long sys_setgid(gid_t gid)
 		return -EPERM;
 
 	key_fsgid_changed(current);
-	return 0;
+	return security_task_post_setgid(gid, -1, -1, LSM_SETID_ID);
 }
   
 static int set_user(uid_t new_ruid, int dumpclear)
@@ -801,6 +801,9 @@ asmlinkage long sys_getresuid(uid_t __us
  */
 asmlinkage long sys_setresgid(gid_t rgid, gid_t egid, gid_t sgid)
 {
+	gid_t old_rgid = current->gid;
+	gid_t old_egid = current->egid;
+	gid_t old_sgid = current->sgid;
 	int retval;
 
 	retval = security_task_setgid(rgid, egid, sgid, LSM_SETID_RES);
@@ -833,7 +836,7 @@ asmlinkage long sys_setresgid(gid_t rgid
 		current->sgid = sgid;
 
 	key_fsgid_changed(current);
-	return 0;
+	return security_task_post_setgid(old_rgid, old_egid, old_sgid, LSM_SETID_RES);
 }
 
 asmlinkage long sys_getresgid(gid_t __user *rgid, gid_t __user *egid, gid_t __user *sgid)
diff -dpru linux-2.6.13-rc1-git3-20050706140055/security/dummy.c AS17/security/dummy.c
--- linux-2.6.13-rc1-git3-20050706140055/security/dummy.c	2005-07-07 20:53:51.000000000 +0200
+++ AS17/security/dummy.c	2005-07-14 23:26:27.000000000 +0200
@@ -518,6 +518,11 @@ static int dummy_task_setgid (gid_t id0,
 	return 0;
 }
 
+static int dummy_task_post_setgid(gid_t id0, gid_t id1, gid_t id2, int flags)
+{
+	return 0;
+}
+
 static int dummy_task_setpgid (struct task_struct *p, pid_t pgid)
 {
 	return 0;
@@ -931,6 +936,7 @@ void security_fixup_ops (struct security
 	set_to_dummy_if_null(ops, task_setuid);
 	set_to_dummy_if_null(ops, task_post_setuid);
 	set_to_dummy_if_null(ops, task_setgid);
+	set_to_dummy_if_null(ops, task_post_setgid);
 	set_to_dummy_if_null(ops, task_setpgid);
 	set_to_dummy_if_null(ops, task_getpgid);
 	set_to_dummy_if_null(ops, task_getsid);
#eof


Jan Engelhardt
-- 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Add security_task_post_setgid
  2005-07-14 21:42 [PATCH] Add security_task_post_setgid Jan Engelhardt
@ 2005-07-14 22:38 ` Christoph Hellwig
  2005-07-15  7:54   ` Jan Engelhardt
  2005-07-14 23:14 ` [PATCH] " Chris Wright
  1 sibling, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2005-07-14 22:38 UTC (permalink / raw)
  To: Jan Engelhardt; +Cc: Linux Kernel Mailing List

On Thu, Jul 14, 2005 at 11:42:46PM +0200, Jan Engelhardt wrote:
> Hi,
> 
> 
> the following patch adds a post_setgid() security hook, and necessary dummy 
> funcs.

... and why exactly would we want these?


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Add security_task_post_setgid
  2005-07-14 21:42 [PATCH] Add security_task_post_setgid Jan Engelhardt
  2005-07-14 22:38 ` Christoph Hellwig
@ 2005-07-14 23:14 ` Chris Wright
  1 sibling, 0 replies; 7+ messages in thread
From: Chris Wright @ 2005-07-14 23:14 UTC (permalink / raw)
  To: Jan Engelhardt; +Cc: Linux Kernel Mailing List

* Jan Engelhardt (jengelh@linux01.gwdg.de) wrote:
> the following patch adds a post_setgid() security hook, and necessary dummy 
> funcs.

why?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Add security_task_post_setgid
  2005-07-14 22:38 ` Christoph Hellwig
@ 2005-07-15  7:54   ` Jan Engelhardt
  2005-07-15 14:32     ` Christoph Hellwig
  0 siblings, 1 reply; 7+ messages in thread
From: Jan Engelhardt @ 2005-07-15  7:54 UTC (permalink / raw)
  To: Christoph Hellwig, Chris Wright; +Cc: Linux Kernel Mailing List


>> the following patch adds a post_setgid() security hook, and necessary dummy 
>> funcs.
>
>... and why exactly would we want these?

I am working on a sec module which, among other things, raises certain 
capabilities when the UID/GID has been successfully changed.


Jan Engelhardt
-- 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Add security_task_post_setgid
  2005-07-15  7:54   ` Jan Engelhardt
@ 2005-07-15 14:32     ` Christoph Hellwig
  2005-07-15 14:50       ` Jan Engelhardt
  0 siblings, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2005-07-15 14:32 UTC (permalink / raw)
  To: Jan Engelhardt; +Cc: Christoph Hellwig, Chris Wright, Linux Kernel Mailing List

On Fri, Jul 15, 2005 at 09:54:40AM +0200, Jan Engelhardt wrote:
> 
> >> the following patch adds a post_setgid() security hook, and necessary dummy 
> >> funcs.
> >
> >... and why exactly would we want these?
> 
> I am working on a sec module which, among other things, raises certain 
> capabilities when the UID/GID has been successfully changed.

So keep the patch part of your module, it has no business in mainline
so far.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Add security_task_post_setgid
  2005-07-15 14:32     ` Christoph Hellwig
@ 2005-07-15 14:50       ` Jan Engelhardt
  2005-07-15 16:30         ` Chris Wright
  0 siblings, 1 reply; 7+ messages in thread
From: Jan Engelhardt @ 2005-07-15 14:50 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Chris Wright, Linux Kernel Mailing List


>So keep the patch part of your module, it has no business in mainline
>so far.

And when is this becoming business? What made post_setUid go into the kernel?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Add security_task_post_setgid
  2005-07-15 14:50       ` Jan Engelhardt
@ 2005-07-15 16:30         ` Chris Wright
  0 siblings, 0 replies; 7+ messages in thread
From: Chris Wright @ 2005-07-15 16:30 UTC (permalink / raw)
  To: Jan Engelhardt; +Cc: Christoph Hellwig, Chris Wright, Linux Kernel Mailing List

* Jan Engelhardt (jengelh@linux01.gwdg.de) wrote:
> And when is this becoming business? What made post_setUid go into the kernel?

That went as part of supporting capabilities as they were, to do fixups
on set{r,e,s}uid.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-07-15 16:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-14 21:42 [PATCH] Add security_task_post_setgid Jan Engelhardt
2005-07-14 22:38 ` Christoph Hellwig
2005-07-15  7:54   ` Jan Engelhardt
2005-07-15 14:32     ` Christoph Hellwig
2005-07-15 14:50       ` Jan Engelhardt
2005-07-15 16:30         ` Chris Wright
2005-07-14 23:14 ` [PATCH] " Chris Wright

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®