Hi Kees,
An unprivileged user can make Yama read a freed task_struct with the
default ptrace_scope=1. relation->tracer is stored without a reference,
and yama_task_free() marks the relation invalid only just before the
task is freed, so a concurrent ptracer_exception_found() can still
dereference it in task_is_descendant(). The KASAN report, the details
and the fix are in the patch below.
This is the problem Oleg Nesterov described on LKML on 2018-10-29
("yama: unsafe usage of ptrace_relation->tracer"). It was never fixed.
Affected (reproduced under KASAN as uid 65534):
- mainline 4405c18c95d2 (v7.4-rc3-230)
- stable 6.12.118
[ ... ]
Link: https://lore.kernel.org/all/0000000000004904df0578b7d3da@google.com/T/ (local)
Fixes: 93b69d437eff ("Yama: add RCU to drop read locking")
Cc: <redacted>
Signed-off-by: JunYoung Lee <redacted>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261119025918.86247-1-ljyoung04@gmail.com?part=1