Files
Oleg Nesterov 6768ecea00 posix-cpu-timers: fix race between handle_posix_cpu_timers() and posix_cpu_timer_del()
If an exiting non-autoreaping task has already passed exit_notify() and
calls handle_posix_cpu_timers() from IRQ, it can be reaped by its parent
or debugger right after unlock_task_sighand().

If a concurrent posix_cpu_timer_del() runs at that moment, it won't be
able to detect timer->it.cpu.firing != 0: cpu_timer_task_rcu() and/or
lock_task_sighand() will fail.

Add the tsk->exit_state check into run_posix_cpu_timers() to fix this.

This fix is not needed if CONFIG_POSIX_CPU_TIMERS_TASK_WORK=y, because
exit_task_work() is called before exit_notify(). But the check still
makes sense, task_work_add(&tsk->posix_cputimers_work.work) will fail
anyway in this case.

Cc: stable@vger.kernel.org
Reported-by: Benoît Sevens <bsevens@google.com>
Fixes: 0bdd2ed413 ("sched: run_posix_cpu_timers: Don't check ->exit_state, use lock_task_sighand()")
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit f90fff1e152dedf52b932240ebbd670d83330eca)

Bug 5341153

CVE-2025-38352
Change-Id: I2146869cc8f9684d4e4d56eaa247f54ed0225e1e
Signed-off-by: Brad Griffis <bgriffis@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/3rdparty/canonical/linux-noble/+/3435903
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Paritosh Dixit <paritoshd@nvidia.com>
2025-08-20 09:12:13 -07:00
..
2025-06-25 11:17:16 -04:00
2024-08-13 12:12:56 +02:00
2025-01-17 14:43:47 +03:00
2025-06-25 11:17:16 -04:00
2025-06-25 11:17:16 -04:00
2022-09-26 10:13:13 -07:00
2023-03-24 11:01:29 +01:00
2023-10-19 11:02:48 +02:00
2023-10-09 16:59:47 +10:00
2025-06-25 11:17:17 -04:00
2025-02-14 15:50:39 +03:00
2025-06-15 10:37:35 +03:00
2025-06-25 11:06:07 -04:00
2023-12-01 09:51:44 -08:00
2023-12-12 14:24:14 +01:00
2020-07-27 14:31:12 -04:00
2023-10-04 10:41:57 -07:00
2023-12-29 12:22:29 -08:00
2023-10-11 08:46:01 -07:00
2020-08-19 14:13:20 +02:00