Skip to contentSkip to conversation

Yama: replace capable() with ns_capable()

PATCH In review Kees Cook 2 participants 2 messages May 14, 2012 – May 15, 2012

Subsystems (2)
lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 Yama: replace capable() with ns_capable()

When checking capabilities, the question we want to be asking is "does current() have the capability in the child's namespace?"

---
 security/yama/yama_lsm.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
security/yama/yama_lsm.c +2 -2
index afb04cb..7ba673b 100644
@@ -264,11 +264,11 @@ static int yama_ptrace_access_check(struct task_struct *child,
 		case YAMA_SCOPE_RELATIONAL:
 			if (!task_is_descendant(current, child) &&
 			    !ptracer_exception_found(current, child) &&
-			    !capable(CAP_SYS_PTRACE))
+			    !ns_capable(task_user_ns(child), CAP_SYS_PTRACE))
 				rc = -EPERM;
 			break;
 		case YAMA_SCOPE_CAPABILITY:
-			if (!capable(CAP_SYS_PTRACE))
+			if (!ns_capable(task_user_ns(child), CAP_SYS_PTRACE))
 				rc = -EPERM;
 			break;
 		case YAMA_SCOPE_NO_ATTACH:
Signature · 5 lines
1.7.0.4

-- 
Kees Cook
Chrome OS Security
maintainer
#1 lore raw
Quoted 4 lines · Kees Cook

When checking capabilities, the question we want to be asking is "does current() have the capability in the child's namespace?"

Applied to
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git next

Signature · 2 lines
James Morris
<[email protected]>