mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] track capabilities in default dummy security module code
@ 2005-01-04 21:33 Chris Wright
  2005-01-04 23:24 ` Chris Wright
  0 siblings, 1 reply; 2+ messages in thread
From: Chris Wright @ 2005-01-04 21:33 UTC (permalink / raw)
  To: akpm, torvalds; +Cc: linux-kernel

Switch dummy logic around to set cap_* bits during exec and set*uid based
on basic uid check.  Then check cap_* bits during capable() (rather than
doing basic uid check).  This ensures that capability bits are properly
initialized in case the capability module is later loaded.

Signed-off-by: Chris Wright <chrisw@osdl.org>

===== security/dummy.c 1.49 vs edited =====
--- 1.49/security/dummy.c	2005-01-03 15:49:14 -08:00
+++ edited/security/dummy.c	2005-01-04 13:14:10 -08:00
@@ -74,11 +74,8 @@ static int dummy_acct (struct file *file
 
 static int dummy_capable (struct task_struct *tsk, int cap)
 {
-	if (cap_is_fs_cap (cap) ? tsk->fsuid == 0 : tsk->euid == 0)
-		/* capability granted */
+	if (cap_raised (tsk->cap_effective, cap))
 		return 0;
-
-	/* capability denied */
 	return -EPERM;
 }
 
@@ -183,6 +180,7 @@ static int dummy_bprm_alloc_security (st
 
 static void dummy_bprm_free_security (struct linux_binprm *bprm)
 {
+	dummy_capget(current, &current->cap_effective, &current->cap_inheritable, &current->cap_permitted);
 	return;
 }
 
@@ -558,6 +556,7 @@ static int dummy_task_setuid (uid_t id0,
 
 static int dummy_task_post_setuid (uid_t id0, uid_t id1, uid_t id2, int flags)
 {
+	dummy_capget(current, &current->cap_effective, &current->cap_inheritable, &current->cap_permitted);
 	return 0;
 }
 

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

* Re: [PATCH] track capabilities in default dummy security module code
  2005-01-04 21:33 [PATCH] track capabilities in default dummy security module code Chris Wright
@ 2005-01-04 23:24 ` Chris Wright
  0 siblings, 0 replies; 2+ messages in thread
From: Chris Wright @ 2005-01-04 23:24 UTC (permalink / raw)
  To: akpm, torvalds; +Cc: linux-kernel, sds, chrisw

* Chris Wright (chrisw@osdl.org) wrote:
> Switch dummy logic around to set cap_* bits during exec and set*uid based
> on basic uid check.  Then check cap_* bits during capable() (rather than
> doing basic uid check).  This ensures that capability bits are properly
> initialized in case the capability module is later loaded.

OK, somehow I managed to botch this one.  It happens to work fine, but I
should have been more careful with forward porting this 1+ year old patch.
The exec-time calc should go in bprm_apply_creds, not bprm_free_security.
Thanks to Stephen for spotting my mistake.

Signed-off-by: Chris Wright <chrisw@osdl.org>

===== security/dummy.c 1.50 vs edited =====
--- 1.50/security/dummy.c	2005-01-04 13:14:10 -08:00
+++ edited/security/dummy.c	2005-01-04 14:45:31 -08:00
@@ -180,7 +180,6 @@ static int dummy_bprm_alloc_security (st
 
 static void dummy_bprm_free_security (struct linux_binprm *bprm)
 {
-	dummy_capget(current, &current->cap_effective, &current->cap_inheritable, &current->cap_permitted);
 	return;
 }
 
@@ -197,6 +196,8 @@ static void dummy_bprm_apply_creds (stru
 
 	current->suid = current->euid = current->fsuid = bprm->e_uid;
 	current->sgid = current->egid = current->fsgid = bprm->e_gid;
+
+	dummy_capget(current, &current->cap_effective, &current->cap_inheritable, &current->cap_permitted);
 }
 
 static int dummy_bprm_set_security (struct linux_binprm *bprm)

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

end of thread, other threads:[~2005-01-05  0:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-04 21:33 [PATCH] track capabilities in default dummy security module code Chris Wright
2005-01-04 23:24 ` 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®