WSL2-Linux-Kernel/fs/proc
Oleg Nesterov fd63fb84ed fs/proc: do_task_stat: move thread_group_cputime_adjusted() outside of lock_task_sighand()
[ Upstream commit 60f92acb60a989b14e4b744501a0df0f82ef30a3 ]

Patch series "fs/proc: do_task_stat: use sig->stats_".

do_task_stat() has the same problem as getrusage() had before "getrusage:
use sig->stats_lock rather than lock_task_sighand()": a hard lockup.  If
NR_CPUS threads call lock_task_sighand() at the same time and the process
has NR_THREADS, spin_lock_irq will spin with irqs disabled O(NR_CPUS *
NR_THREADS) time.

This patch (of 3):

thread_group_cputime() does its own locking, we can safely shift
thread_group_cputime_adjusted() which does another for_each_thread loop
outside of ->siglock protected section.

Not only this removes for_each_thread() from the critical section with
irqs disabled, this removes another case when stats_lock is taken with
siglock held.  We want to remove this dependency, then we can change the
users of stats_lock to not disable irqs.

Link: https://lkml.kernel.org/r/20240123153313.GA21832@redhat.com
Link: https://lkml.kernel.org/r/20240123153355.GA21854@redhat.com
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Dylan Hatch <dylanbhatch@google.com>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-15 10:48:22 -04:00
..
Kconfig
Makefile
array.c fs/proc: do_task_stat: move thread_group_cputime_adjusted() outside of lock_task_sighand() 2024-03-15 10:48:22 -04:00
base.c procfs: block chmod on /proc/thread-self/comm 2023-09-19 12:22:52 +02:00
bootconfig.c proc: bootconfig: Add null pointer check 2022-04-08 14:24:12 +02:00
cmdline.c
consoles.c
cpuinfo.c
devices.c
fd.c procfs: prevent unprivileged processes accessing fdinfo dir 2022-05-18 10:26:50 +02:00
fd.h
generic.c proc: fix dentry/inode overinstantiating under /proc/${pid}/net 2022-06-09 10:23:10 +02:00
inode.c
internal.h
interrupts.c
kcore.c
kmsg.c
loadavg.c
meminfo.c
namespaces.c
nommu.c
page.c
proc_net.c proc: fix dentry/inode overinstantiating under /proc/${pid}/net 2022-06-09 10:23:10 +02:00
proc_sysctl.c proc: sysctl: prevent aliased sysctls from getting passed to init 2023-12-03 07:31:24 +01:00
proc_tty.c
root.c
self.c
softirqs.c
stat.c fs/proc/uptime.c: Fix idle time reporting in /proc/uptime 2021-11-18 19:16:13 +01:00
task_mmu.c mm: hugetlb: proc: check for hugetlb shared PMD in /proc/PID/smaps 2023-02-09 11:26:44 +01:00
task_nommu.c proc: nommu: /proc/<pid>/maps: release mmap read lock 2023-10-06 13:18:22 +02:00
thread_self.c
uptime.c fs/proc/uptime.c: Fix idle time reporting in /proc/uptime 2021-11-18 19:16:13 +01:00
util.c
version.c
vmcore.c proc/vmcore: fix clearing user buffer by properly using clear_user() 2021-12-01 09:04:44 +01:00