{"id":"CVE-2026-78118","revision":"d9c5a396a41e4c3da99e0111af2561ab","records":[{"revision":"d9c5a396a41e4c3da99e0111af2561ab","observedAt":"2026-10-23T22:48:20.692+00:00","statement":{"source":"cve-program","id":"CVE-2026-78118","aliases":[],"title":"Race condition on kernel wait queues: unlocked z_waitq_head() read in the timer expiration handler can yield a stale or sentinel thread pointer on SMP","description":"The kernel helper z_waitq_head() (kernel/include/wait_q.h) reads the head of a thread wait queue, but on SMP systems it was called from several places without holding the scheduler spinlock _sched_spinlock that serializes wait-queue mutation. The consequential call site is z_timer_expiration_handler() in kernel/timer.c, which held only the timer subsystem lock timer_lock while reading timer->wait_q and then unpending, setting the return value of, and readying the thread it obtained. halt_thread() in kernel/sched.c removes an aborted thread from its wait queue while holding only _sched_spinlock, so the two paths are not mutually exclusive.\n\nWhen the last waiter is removed on another CPU inside that window, sys_dlist_peek_head() can return the list sentinel — a pointer into the k_timer object itself — typed as a struct k_thread * (with CONFIG_WAITQ_SCALABLE, rb_get_min() can return an arbitrary node of a tree being restructured), or it can return a pointer to a thread that has already been unpended and, for dynamically allocated threads, freed. The handler then calls unpend_thread_no_timeout(), which performs a sys_dlist_remove() through pointers read from that object, and arch_thread_return_value_set(), which writes unconditionally through the pointer.\n\nThe result is out-of-bounds and use-after-free writes in supervisor context, plus scheduler state corruption; a milder outcome is a thread that has re-pended elsewhere being woken with a success return value from an unrelated blocking call. All of the primitives needed to drive the interleaving — k_timer_start(), k_timer_status_sync(), k_thread_create() and k_thread_abort() — are system calls, so with CONFIG_USERSPACE enabled an unprivileged user-mode thread can attempt the race against kernel-owned data.\n\nExploitation requires a multi-CPU build (CONFIG_MP_MAX_NUM_CPUS greater than one; the affected region is a no-op on uniprocessor targets), local code execution, and winning a narrow timing window, so the practical outcome is most often a kernel crash rather than controlled corruption. The fix splits the helper into z_waitq_head_locked() for callers that already hold the scheduler spinlock and a z_waitq_head() that acquires it, and brings the timer expiration handler's head read, unpend and ready under a single LOCK_SCHED_SPINLOCK region.","state":0,"publishedAt":"2026-10-21T18:19:32.2+00:00","modifiedAt":"2026-10-23T21:28:10.701+00:00","affected":[{"ecosystem":"https://github.com/zephyrproject-rtos/zephyr","name":"zephyr","ranges":[],"versions":[],"rawVersionEvidence":"{\n                    \"vendor\": \"zephyrproject\",\n                    \"product\": \"zephyr\",\n                    \"collectionURL\": \"https://github.com/zephyrproject-rtos/zephyr\",\n                    \"packageName\": \"zephyr\",\n                    \"defaultStatus\": \"unaffected\",\n                    \"programFiles\": [\n                        \"kernel/include/wait_q.h\",\n                        \"kernel/msg_q.c\",\n                        \"kernel/mutex.c\",\n                        \"kernel/sched.c\",\n                        \"kernel/stack.c\",\n                        \"kernel/timer.c\",\n                        \"kernel/userspace/userspace.c\"\n                    ],\n                    \"programRoutines\": [\n                        {\n                            \"name\": \"z_timer_expiration_handler\"\n                        },\n                        {\n                            \"name\": \"z_waitq_head\"\n                        }\n                    ],\n                    \"versions\": [\n                        {\n                            \"version\": \"2.2.0\",\n                            \"status\": \"affected\",\n                            \"lessThan\": \"4.5.0\",\n                            \"versionType\": \"semver\"\n                        }\n                    ]\n                }"}],"metrics":[{"system":"CVSS 3.1","vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H","score":7,"severity":"HIGH"}],"references":["https://github.com/zephyrproject-rtos/zephyr/commit/a9b21fb354e8468dd15db307c3e599dc68b7ef33","https://github.com/zephyrproject-rtos/zephyr/security/advisories/GHSA-gm6w-pv43-m3vf"],"sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2026-78118","license":"CVE Program Terms of Use","key":"cve-program:CVE-2026-78118","identifiers":["CVE-2026-78118"]},"retained":false,"historicalAffected":[]}],"coverage":[]}