Files
Centos-kernel-stream-9/kernel
CKI KWF Bot 9a55453fae Merge: CVE-2025-68214: timers: Fix NULL function pointer race in timer_shutdown_sync()
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/8423

JIRA: https://redhat.atlassian.net/browse/RHEL-189941
CVE: CVE-2025-68214

commit 20739af07383e6eb1ec59dcd70b72ebfa9ac362c
Author: Yipeng Zou <zouyipeng@huawei.com>
Date:   Sat, 22 Nov 2025 09:39:42 +0000

    timers: Fix NULL function pointer race in timer_shutdown_sync()

    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
                                            <SOFTIRQ>
                                            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
                                            <SOFTIRQ>
                                            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 <zouyipeng@huawei.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: stable@vger.kernel.org
    Link: https://patch.msgid.link/20251122093942.301559-1-zouyipeng@huawei.com

Signed-off-by: Waiman Long <longman@redhat.com>

Approved-by: Tony Camuso <tcamuso@redhat.com>
Approved-by: Scott Weaver <scweaver@redhat.com>
Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com>

Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
2026-08-04 08:11:52 +00:00
..
2025-08-22 14:40:40 -04:00
2025-12-08 12:31:32 +08:00
2025-12-22 09:16:59 +01:00
2025-08-22 14:40:57 -04:00
2024-09-20 12:26:34 -07:00