[PATCH] yama: fix use-after-free read of a dead PR_SET_PTRACER tracer

sashiko-bot at kernel.org sashiko-bot at kernel.org
Mon Nov 23 17:01:57 UTC 2026


> A PR_SET_PTRACER relation stores a bare pointer to the tracer's
> task_struct.  When the tracer dies, its task_struct is freed via
> call_rcu(), and the relation is only marked invalid from
> security_task_free(), i.e. from the same RCU callback that frees the
> task.  A reader that enters rcu_read_lock() after the callback was
> queued is not protected against it: ptracer_exception_found() can read
> relation->invalid while it is still false and then dereference the
> already freed tracer in task_is_descendant().
> 
> This is a slab-use-after-free read during ptrace access checks, e.g.
> via process_vm_readv(), on mainline v7.4-rc4 (KASAN build):
> 
> BUG: KASAN: slab-use-after-free in task_is_descendant+0x1a3/0x1b0
> Read of size 4 at addr ffff88810a46c598 by task poc/167
> CPU: 6 UID: 1000 PID: 167 Comm: poc
> [ ... ]
> 
> This issue was discovered by Tencent CodeBuddy Security.
> Cc: stable at vger.kernel.org
> Fixes: 93b69d437eff ("Yama: add RCU to drop read locking")
> Signed-off-by: Henry Martin <bsdhenrymartin at gmail.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261123165357.4092273-1-bsdhenrymartin@gmail.com?part=1



More information about the Linux-security-module-archive mailing list