]> git.ipfire.org Git - thirdparty/linux.git/commit
procfs: fix missing RCU protection when reading real_parent in do_task_stat()
authorJinliang Zheng <alexjlzheng@tencent.com>
Wed, 28 Jan 2026 08:30:07 +0000 (16:30 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 8 Feb 2026 08:13:34 +0000 (00:13 -0800)
commit76149d53502cf17ef3ae454ff384551236fba867
tree5cc2da12a118c8794f2327cf5af02d8e4555f3fb
parentcafe4074a7221dca2fa954dd1ab0cf99b6318e23
procfs: fix missing RCU protection when reading real_parent in do_task_stat()

When reading /proc/[pid]/stat, do_task_stat() accesses task->real_parent
without proper RCU protection, which leads to:

  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 uses task_ppid_nr_ns() instead of task_tgid_nr_ns() to add
proper RCU protection for accessing task->real_parent.

Link: https://lkml.kernel.org/r/20260128083007.3173016-1-alexjlzheng@tencent.com
Fixes: 06fffb1267c9 ("do_task_stat: don't take rcu_read_lock()")
Signed-off-by: Jinliang Zheng <alexjlzheng@tencent.com>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Mateusz Guzik <mjguzik@gmail.com>
Cc: ruippan <ruippan@tencent.com>
Cc: Usama Arif <usamaarif642@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/proc/array.c