 posix-cpu-timers: fix race between handle_posix_cpu_timers() and posi… · gregkh/linux@78a4b8e · GitHub Skip to content Navigation Menu Toggle navigation Sign in Appearance settings Platform AI CODE CREATION GitHub Copilot Write better code with AI GitHub Spark Build and deploy intelligent apps GitHub Models Manage and compare prompts MCP Registry New Integrate external tools DEVELOPER WORKFLOWS Actions Automate any workflow Codespaces Instant dev environments Issues Plan and track work Code Review Manage code changes APPLICATION SECURITY GitHub Advanced Security Find and fix vulnerabilities Code security Secure your code as you build Secret protection  EXPLORE Why GitHub Documentation Blog Changelog Marketplace View all features Solutions BY COMPANY SIZE Enterprises Small and medium teams Startups Nonprofits BY USE CASE App Modernization DevSecOps DevOps CI/CD View all use cases BY INDUSTRY Healthcare Financial services Manufacturing Government View all industries View all solutions Resources EXPLORE BY TOPIC AI Software Development DevOps Security View all topics EXPLORE BY TYPE Customer stories Events &amp; webinars Ebooks &amp; reports Business insights GitHub Skills SUPPORT &amp; SERVICES Documentation Customer support Community forum Trust center Partners View all resources Open Source COMMUNITY GitHub Sponsors Fund open source developers PROGRAMS Security Lab Maintainer Community Accelerator GitHub Stars Archive Program REPOSITORIES Topics Trending Collections Enterprise ENTERPRISE SOLUTIONS Enterprise platform AI-powered developer platform AVAILABLE ADD-ONS GitHub Advanced Security Enterprise-grade security features Copilot for Business Enterprise-grade AI features Premium Support Enterprise-grade 24/7 support Pricing Search or jump to... Search code, repositories, users, issues, pull requests... --> Search Clear Search syntax tips Provide feedback --> We read every piece of feedback, and take your input very seriously.  Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly --> Name Query To see all available qualifiers, see our documentation . Cancel Create saved search Sign in Sign up Appearance settings Resetting focus You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} gregkh / linux Public Notifications You must be signed in to change notification settings Fork 676 Star 636 Code Actions Security and quality 0 Insights Additional navigation options Code Actions Security and quality Insights Commit 78a4b8e Browse files Browse files oleg-nesterov authored and gregkh committed posix-cpu-timers: fix race between handle_posix_cpu_timers() and posix_cpu_timer_del() commit f90fff1 upstream. 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-&gt;it.cpu.firing != 0: cpu_timer_task_rcu() and/or lock_task_sighand() will fail. Add the tsk-&gt;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(&amp;tsk-&gt;posix_cputimers_work.work) will fail anyway in this case. Cc: stable@vger.kernel.org Reported-by: Benoît Sevens &lt;bsevens@google.com&gt; Fixes: 0bdd2ed ("sched: run_posix_cpu_timers: Don't check -&gt;exit_state, use lock_task_sighand()") Signed-off-by: Oleg Nesterov &lt;oleg@redhat.com&gt; Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt; Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt; 1 parent 0fee1b2 commit 78a4b8e Copy full SHA for 78a4b8e 1 file changed + 9 Lines changed: 9 additions &amp; 0 deletions File tree Expand file tree Collapse file tree Open diff view settings Filter options kernel/time posix-cpu-timers.c Expand file tree Collapse file tree Open diff view settings Collapse file ‎ kernel/time/posix-cpu-timers.c ‎ Copy file name to clipboard Expand all lines: kernel/time/posix-cpu-timers.c + 9 Lines changed: 9 additions &amp; 0 deletions Original file line number Diff line number Diff line change @@ -1119,6 +1119,15 @@ void run_posix_cpu_timers(void) 1119 1119 1120 1120 lockdep_assert_irqs_disabled (); 1121 1121 1122 + /* 1123 + * Ensure that release_task(tsk) can&#39;t happen while 1124 + * handle_posix_cpu_timers() is running. Otherwise, a concurrent 1125 + * posix_cpu_timer_del() may fail to lock_task_sighand(tsk) and 1126 + * miss timer-&gt;it.cpu.firing != 0. 1127 + */ 1128 + if ( tsk -&gt; exit_state ) 1129 + return ; 1130 + 1122 1131 /* 1123 1132 * The fast path checks that there are no expired thread or thread 1124 1133 * group timers. If that&#39;s so, just return. 0 commit comments Comments 0 ( 0 ) Footer &copy; 2026 GitHub,&nbsp;Inc. Footer navigation Terms Privacy Security Status Community Docs Contact Manage cookies Do not share my personal information You can’t perform that action at this time. 