From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4CC99366561; Thu, 23 Apr 2026 12:35:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776947740; cv=none; b=XltltxjSy7ow+/9zNyvQNqSA4b92r9svB3GTTY5zX6T7pffkalPGZc37nXCzmFWEZ0aTyJMtceIxho+86J1cK5TsJgbBl42LYTCLmMlVXkc/2caCnLUZkMhCJZuHU168fWK6agtZ4raBsot2I9Kc1iC74akHZF6EbUkBQ8Cp4yM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776947740; c=relaxed/simple; bh=xyZM3RmC1iG5eTbXHkyJT/1cOX+Z5OX3mm3DeGXWfjw=; h=Subject:To:Cc:From:Date:In-Reply-To:Message-ID:MIME-Version: Content-Type; b=Xwa6cT2WC9d7z+wN8UXecEHhNMfyg7Qr8WJe5bnV4/NAOs6Qpf5CSzIkzCQ75HXl7tfk8/45oTSDZ2msXrT/FYwoJ5iMXjl9hyuSxd6CQsIR8hrNtvXj4+3HC+0OIbFwdG5RxK/G9/VZ51LuhD8LGfU79pcj8WC20YzyDwbdNhU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=i8T0ydqZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="i8T0ydqZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9AD29C2BCAF; Thu, 23 Apr 2026 12:35:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776947740; bh=xyZM3RmC1iG5eTbXHkyJT/1cOX+Z5OX3mm3DeGXWfjw=; h=Subject:To:Cc:From:Date:In-Reply-To:From; b=i8T0ydqZBN3IHFm/MKpAthSBlsai4P8uJdodvTC3SpPp4LOYEQ3jOYUvH+PaxnkfH 7nBqk/Kco8ETx4SIlKa7jVkTJEAfQXqmdroZlqJ8QS7sKsD+ZmAq2GNexbGyn8HBjv RwJY7aX5yZjqjhLTBJzFIRd4IvjeIYVJ27f5zLJY= Subject: Patch "timers: Fix NULL function pointer race in timer_shutdown_sync()" has been added to the 5.10-stable tree To: Julia.Lawall@inria.fr,aha310510@gmail.com,akpm@linux-foundation.org,anna-maria@linutronix.de,arnd@arndb.de,gregkh@linuxfoundation.org,linux-staging@lists.linux.dev,linux@roeck-us.net,luiz.dentz@gmail.com,marcel@holtmann.org,maz@kernel.org,peterz@infradead.org,rostedt@goodmis.org,sboyd@kernel.org,tglx@linutronix.de,viresh.kumar@linaro.org,zouyipeng@huawei.com Cc: From: Date: Thu, 23 Apr 2026 14:35:07 +0200 In-Reply-To: <20260219171310.118170-16-aha310510@gmail.com> Message-ID: <2026042307-freckled-chafe-30d0@gregkh> Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit X-stable: commit X-Patchwork-Hint: ignore This is a note to let you know that I've just added the patch titled timers: Fix NULL function pointer race in timer_shutdown_sync() to the 5.10-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: timers-fix-null-function-pointer-race-in-timer_shutdown_sync.patch and it can be found in the queue-5.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >From aha310510@gmail.com Thu Feb 19 18:14:19 2026 From: Jeongjun Park Date: Fri, 20 Feb 2026 02:13:10 +0900 Subject: timers: Fix NULL function pointer race in timer_shutdown_sync() To: stable@vger.kernel.org Cc: gregkh@linuxfoundation.org, tglx@linutronix.de, Julia.Lawall@inria.fr, akpm@linux-foundation.org, anna-maria@linutronix.de, arnd@arndb.de, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, linux@roeck-us.net, luiz.dentz@gmail.com, marcel@holtmann.org, maz@kernel.org, peterz@infradead.org, rostedt@goodmis.org, sboyd@kernel.org, viresh.kumar@linaro.org, zouyipeng@huawei.com, aha310510@gmail.com, linux-staging@lists.linux.dev Message-ID: <20260219171310.118170-16-aha310510@gmail.com> From: Yipeng Zou [ Upstream commit 20739af07383e6eb1ec59dcd70b72ebfa9ac362c ] There is a race condition between timer_shutdown_sync() and timer expiration that can lead to hitting a WARN_ON in expire_timers(). The issue occurs when timer_shutdown_sync() clears the timer function to NULL while the timer is still running on another CPU. The race scenario looks like this: CPU0 CPU1 lock_timer_base() expire_timers() base->running_timer = timer; unlock_timer_base() [call_timer_fn enter] mod_timer() ... timer_shutdown_sync() lock_timer_base() // For now, will not detach the timer but only clear its function to NULL if (base->running_timer != timer) ret = detach_if_pending(timer, base, true); if (shutdown) timer->function = NULL; unlock_timer_base() [call_timer_fn exit] lock_timer_base() base->running_timer = NULL; unlock_timer_base() ... // Now timer is pending while its function set to NULL. // next timer trigger expire_timers() WARN_ON_ONCE(!fn) // hit ... lock_timer_base() // Now timer will detach if (base->running_timer != timer) ret = detach_if_pending(timer, base, true); if (shutdown) timer->function = NULL; unlock_timer_base() The problem is that timer_shutdown_sync() clears the timer function regardless of whether the timer is currently running. This can leave a pending timer with a NULL function pointer, which triggers the WARN_ON_ONCE(!fn) check in expire_timers(). Fix this by only clearing the timer function when actually detaching the timer. If the timer is running, leave the function pointer intact, which is safe because the timer will be properly detached when it finishes running. Fixes: 0cc04e80458a ("timers: Add shutdown mechanism to the internal functions") Signed-off-by: Yipeng Zou Signed-off-by: Thomas Gleixner Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20251122093942.301559-1-zouyipeng@huawei.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- kernel/time/timer.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1360,10 +1360,11 @@ static int __try_to_del_timer_sync(struc base = lock_timer_base(timer, &flags); - if (base->running_timer != timer) + if (base->running_timer != timer) { ret = detach_if_pending(timer, base, true); - if (shutdown) - timer->function = NULL; + if (shutdown) + timer->function = NULL; + } raw_spin_unlock_irqrestore(&base->lock, flags); Patches currently in stable-queue which might be from aha310510@gmail.com are queue-5.10/timers-update-the-documentation-to-reflect-on-the-new-timer_shutdown-api.patch queue-5.10/clocksource-drivers-arm_arch_timer-do-not-use-timer-namespace-for-timer_shutdown-function.patch queue-5.10/timers-split-del_timer-to-prepare-for-shutdown-mode.patch queue-5.10/arm-spear-do-not-use-timer-namespace-for-timer_shutdown-function.patch queue-5.10/media-as102-fix-to-not-free-memory-after-the-device-is-registered-in-as102_usb_probe.patch queue-5.10/timers-add-shutdown-mechanism-to-the-internal-functions.patch queue-5.10/timers-provide-timer_shutdown.patch queue-5.10/timers-rename-del_timer-to-timer_delete.patch queue-5.10/timers-replace-bug_on-s.patch queue-5.10/bluetooth-hci_qca-fix-the-teardown-problem-for-real.patch queue-5.10/timers-fix-null-function-pointer-race-in-timer_shutdown_sync.patch queue-5.10/documentation-replace-del_timer-del_timer_sync.patch queue-5.10/documentation-remove-bogus-claim-about-del_timer_sync.patch queue-5.10/timers-silently-ignore-timers-with-a-null-function.patch queue-5.10/timers-get-rid-of-del_singleshot_timer_sync.patch queue-5.10/media-hackrf-fix-to-not-free-memory-after-the-device-is-registered-in-hackrf_probe.patch queue-5.10/clocksource-drivers-sp804-do-not-use-timer-namespace-for-timer_shutdown-function.patch