fs/proc: do_task_stat: use sig->stats_lock to gather the threads/children stats
mainline inclusion from mainline-v6.8-rc4 commit 7601df8031fd67310af891897ef6cc0df4209305 category: bugfix bugzilla: https://gitee.com/src-openeuler/kernel/issues/I9E2EL CVE: CVE-2024-26686 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7601df8031fd67310af891897ef6cc0df4209305 -------------------------------- 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:
Zhao Wenhui <zhaowenhui8@huawei.com>
Loading
Please sign in to comment