linux-kernelorg-stable/kernel/time
Oleg Nesterov f90fff1e15 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>
2025-06-13 10:55:49 -07:00
..
Kconfig
Makefile
alarmtimer.c alarmtimer: Switch spin_{lock,unlock}_irqsave() to guards 2025-04-30 09:06:23 +02:00
clockevents.c
clocksource-wdtest.c
clocksource.c clocksource: Fix the CPUs' choice in the watchdog per CPU verification 2025-05-13 15:38:55 +02:00
hrtimer.c hrtimer: Add missing ACCESS_PRIVATE() for hrtimer::function 2025-04-09 21:00:42 +02:00
itimer.c
jiffies.c time/jiffies: Change register_refined_jiffies() to void __init 2025-04-30 09:06:23 +02:00
namespace.c
ntp.c
ntp_internal.h
posix-clock.c
posix-cpu-timers.c posix-cpu-timers: fix race between handle_posix_cpu_timers() and posix_cpu_timer_del() 2025-06-13 10:55:49 -07:00
posix-stubs.c
posix-timers.c posix-timers: Initialize cache early and move pointer into __timer_data 2025-04-09 21:21:36 +02:00
posix-timers.h
sched_clock.c
sleep_timeout.c treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
test_udelay.c
tick-broadcast-hrtimer.c
tick-broadcast.c
tick-common.c timekeeping: Add a lockdep override in tick_freeze() 2025-04-09 22:30:39 +02:00
tick-internal.h
tick-legacy.c
tick-oneshot.c
tick-sched.c
tick-sched.h
time.c
time_test.c
timeconst.bc
timeconv.c
timecounter.c
timekeeping.c timekeeping: Prevent coarse clocks going backwards 2025-04-28 11:17:29 +02:00
timekeeping.h
timekeeping_debug.c
timekeeping_internal.h
timer.c Updates for the time/timer core code: 2025-05-27 09:04:15 -07:00
timer_list.c
timer_migration.c
timer_migration.h
vsyscall.c timekeeping: Prevent coarse clocks going backwards 2025-04-28 11:17:29 +02:00