Skip to content

Commit 465954c

Browse files
oleg-nesterovpcmoore
authored andcommitted
selinux: selinux_setprocattr()->ptrace_parent() needs rcu_read_lock()
selinux_setprocattr() does ptrace_parent(p) under task_lock(p), but task_struct->alloc_lock doesn't pin ->parent or ->ptrace, this looks confusing and triggers the "suspicious RCU usage" warning because ptrace_parent() does rcu_dereference_check(). And in theory this is wrong, spin_lock()->preempt_disable() doesn't necessarily imply rcu_read_lock() we need to access the ->parent. Reported-by: Evan McNabb <[email protected]> Signed-off-by: Oleg Nesterov <[email protected]> Cc: [email protected] Signed-off-by: Paul Moore <[email protected]>
1 parent a5e333d commit 465954c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

security/selinux/hooks.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5583,11 +5583,11 @@ static int selinux_setprocattr(struct task_struct *p,
55835583
/* Check for ptracing, and update the task SID if ok.
55845584
Otherwise, leave SID unchanged and fail. */
55855585
ptsid = 0;
5586-
task_lock(p);
5586+
rcu_read_lock();
55875587
tracer = ptrace_parent(p);
55885588
if (tracer)
55895589
ptsid = task_sid(tracer);
5590-
task_unlock(p);
5590+
rcu_read_unlock();
55915591

55925592
if (tracer) {
55935593
error = avc_has_perm(ptsid, sid, SECCLASS_PROCESS,

0 commit comments

Comments
 (0)