public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Smack: replace capable() with ns_capable()
@ 2015-07-24 11:26 Sungbae Yoo
  2015-07-24 11:40 ` Lukasz Pawelczyk
  0 siblings, 1 reply; 8+ messages in thread
From: Sungbae Yoo @ 2015-07-24 11:26 UTC (permalink / raw)
  To: Casey Schaufler
  Cc: James Morris, Serge E. Hallyn, linux-security-module,
	linux-kernel, Sungbae Yoo

If current task has capabilities, Smack operations (eg. Changing own smack
label) should be available even inside of namespace.

Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>

diff --git a/security/smack/smack_access.c b/security/smack/smack_access.c
index 00f6b38..f6b2c35 100644
--- a/security/smack/smack_access.c
+++ b/security/smack/smack_access.c
@@ -639,7 +639,7 @@ int smack_privileged(int cap)
 	struct smack_known *skp = smk_of_current();
 	struct smack_onlycap *sop;
 
-	if (!capable(cap))
+	if (!ns_capable(current_user_ns(), cap))
 		return 0;
 
 	rcu_read_lock();
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index a143328..7fdc3dd 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -403,7 +403,8 @@ static int smk_ptrace_rule_check(struct task_struct *tracer,
 			rc = 0;
 		else if (smack_ptrace_rule == SMACK_PTRACE_DRACONIAN)
 			rc = -EACCES;
-		else if (capable(CAP_SYS_PTRACE))
+		else if (ns_capable(__task_cred(tracer)->user_ns,
+				    CAP_SYS_PTRACE))
 			rc = 0;
 		else
 			rc = -EACCES;
-- 
1.9.1


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

end of thread, other threads:[~2015-07-28 16:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-24 11:26 [PATCH] Smack: replace capable() with ns_capable() Sungbae Yoo
2015-07-24 11:40 ` Lukasz Pawelczyk
2015-07-25 16:59   ` Casey Schaufler
2015-07-27  1:27   ` Sungbae Yoo
2015-07-27  8:52     ` Lukasz Pawelczyk
2015-07-28 14:36     ` Casey Schaufler
2015-07-28 15:06       ` Serge E. Hallyn
2015-07-28 16:11         ` Casey Schaufler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox