]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
fs/proc: do_task_stat: use sig->stats_lock to gather the threads/children stats
authorOleg Nesterov <oleg@redhat.com>
Tue, 23 Jan 2024 15:33:57 +0000 (16:33 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 May 2025 05:44:24 +0000 (07:44 +0200)
commit0c35d1914353799c54fa1843fe7dea6fcbcdbac5
treeee57dc645ab04f2eca87ad3d61dfcb9dbff02593
parent7d21587d35bc816c85a51b8686f0f7e8e676fb14
fs/proc: do_task_stat: use sig->stats_lock to gather the threads/children stats

commit 7601df8031fd67310af891897ef6cc0df4209305 upstream.

lock_task_sighand() can trigger a hard lockup.  If NR_CPUS threads call
do_task_stat() at the same time and the process has NR_THREADS, it will
spin with irqs disabled O(NR_CPUS * NR_THREADS) time.

Change do_task_stat() to use sig->stats_lock to gather the statistics
outside of ->siglock protected section, in the likely case this code will
run lockless.

Link: https://lkml.kernel.org/r/20240123153357.GA21857@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>
Signed-off-by: David Sauerwein <dssauerw@amazon.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/proc/array.c