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: 0bdd2ed4 ("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>
-
mentioned in commit 3a9e9d46
-
mentioned in commit 8ce30a9f
-
mentioned in commit f8788310
-
mentioned in commit f5ac1bdc
-
mentioned in commit f997514b
-
mentioned in commit 65607724
-
mentioned in commit bc801e85
-
mentioned in commit caea3d66
-
mentioned in commit 2b5aab29
-
mentioned in commit b0853d92
-
mentioned in commit 1bfd3970
-
mentioned in commit f9c3d286
-
mentioned in commit 5bf0eeab
-
mentioned in commit 41122b1e
-
mentioned in commit b3648997
-
mentioned in commit 94a8622e
-
mentioned in commit 0b6b42f4
-
mentioned in commit 4a597f7a
-
mentioned in commit add9a36f
-
mentioned in commit 8713724d
-
mentioned in commit 6aefbc22
-
mentioned in commit 896c7e55
-
mentioned in commit 46a5565a
-
mentioned in commit ce37d815
-
mentioned in commit cb99ca28
-
mentioned in commit d9d8371c
-
mentioned in commit 02a8438f
-
mentioned in commit ecd05245
-
mentioned in commit f2130917
-
mentioned in commit 47235f57
-
mentioned in commit e654aebb
-
mentioned in commit 85fe33fb
-
mentioned in commit 157f357d
-
mentioned in commit 233cd6b5
-
mentioned in commit eb3177c7
-
mentioned in commit 78f9bd45
-
mentioned in commit 295e2a83
-
mentioned in commit 24945b79
-
mentioned in commit cfb95db9
-
mentioned in commit 2b97cd74
-
mentioned in commit 04fade13
-
mentioned in commit c37fd26e
-
mentioned in commit ef7574a6
-
mentioned in commit 6c330775
-
mentioned in commit e7566177
-
mentioned in commit 40747f5f
-
mentioned in commit 1bf1aa36
-
mentioned in commit c5bb3190
-
mentioned in commit b64c8a8c
-
mentioned in commit fd288f29
-
mentioned in commit d681ed49
-
mentioned in commit 3da69d70
-
mentioned in commit c7d3f561
-
mentioned in commit 52ee0ae5
-
mentioned in commit 087a3ddc
-
mentioned in commit ad88e38b
-
mentioned in commit 6562abcd
-
mentioned in commit 1a1c0fd6
-
mentioned in commit 789e6971
-
mentioned in commit 08115cdf
-
mentioned in commit 33429dd3
-
mentioned in commit a40d88b6