aboutsummaryrefslogtreecommitdiffstats
path: root/security/yama/yama_lsm.c
diff options
context:
space:
mode:
Diffstat (limited to 'security/yama/yama_lsm.c')
-rw-r--r--security/yama/yama_lsm.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
index b4c29848b49d..0e72239aeb05 100644
--- a/security/yama/yama_lsm.c
+++ b/security/yama/yama_lsm.c
@@ -262,14 +262,18 @@ int yama_ptrace_access_check(struct task_struct *child,
262 /* No additional restrictions. */ 262 /* No additional restrictions. */
263 break; 263 break;
264 case YAMA_SCOPE_RELATIONAL: 264 case YAMA_SCOPE_RELATIONAL:
265 rcu_read_lock();
265 if (!task_is_descendant(current, child) && 266 if (!task_is_descendant(current, child) &&
266 !ptracer_exception_found(current, child) && 267 !ptracer_exception_found(current, child) &&
267 !ns_capable(task_user_ns(child), CAP_SYS_PTRACE)) 268 !ns_capable(__task_cred(child)->user_ns, CAP_SYS_PTRACE))
268 rc = -EPERM; 269 rc = -EPERM;
270 rcu_read_unlock();
269 break; 271 break;
270 case YAMA_SCOPE_CAPABILITY: 272 case YAMA_SCOPE_CAPABILITY:
271 if (!ns_capable(task_user_ns(child), CAP_SYS_PTRACE)) 273 rcu_read_lock();
274 if (!ns_capable(__task_cred(child)->user_ns, CAP_SYS_PTRACE))
272 rc = -EPERM; 275 rc = -EPERM;
276 rcu_read_unlock();
273 break; 277 break;
274 case YAMA_SCOPE_NO_ATTACH: 278 case YAMA_SCOPE_NO_ATTACH:
275 default: 279 default:
@@ -307,8 +311,10 @@ int yama_ptrace_traceme(struct task_struct *parent)
307 /* Only disallow PTRACE_TRACEME on more aggressive settings. */ 311 /* Only disallow PTRACE_TRACEME on more aggressive settings. */
308 switch (ptrace_scope) { 312 switch (ptrace_scope) {
309 case YAMA_SCOPE_CAPABILITY: 313 case YAMA_SCOPE_CAPABILITY:
310 if (!ns_capable(task_user_ns(parent), CAP_SYS_PTRACE)) 314 rcu_read_lock();
315 if (!ns_capable(__task_cred(parent)->user_ns, CAP_SYS_PTRACE))
311 rc = -EPERM; 316 rc = -EPERM;
317 rcu_read_unlock();
312 break; 318 break;
313 case YAMA_SCOPE_NO_ATTACH: 319 case YAMA_SCOPE_NO_ATTACH:
314 rc = -EPERM; 320 rc = -EPERM;