Re: [PATCH v2] procfs: fix missing RCU protection when reading real_parent in do_task_stat()

From: Oleg Nesterov

Date: Wed Jan 28 2026 - 03:49:50 EST


On 01/28, alexjlzheng@xxxxxxxxx wrote:
>
> From: Jinliang Zheng <alexjlzheng@xxxxxxxxxxx>
>
> When reading /proc/[pid]/stat, do_task_stat() accesses task->real_parent
> without proper RCU protection, which leads:
>
> cpu 0 cpu 1
> ----- -----
> do_task_stat
> var = task->real_parent
> release_task
> call_rcu(delayed_put_task_struct)
> task_tgid_nr_ns(var)
> rcu_read_lock <--- Too late to protect task->real_parent!
> task_pid_ptr <--- UAF!
> rcu_read_unlock
>
> This patch use task_ppid_nr_ns() instead of task_tgid_nr_ns() to adds
> proper RCU protection for accessing task->real_parent.
>
> Fixes: 06fffb1267c9 ("do_task_stat: don't take rcu_read_lock()")
> Signed-off-by: Jinliang Zheng <alexjlzheng@xxxxxxxxxxx>

Acked-by: Oleg Nesterov <oleg@xxxxxxxxxx>