{"id":"CVE-2026-139558","summary":"sched: Set TIF_NEED_RESCHED before calling __trace_set_need_resched()","details":"In the Linux kernel, the following vulnerability has been resolved:\n\nsched: Set TIF_NEED_RESCHED before calling __trace_set_need_resched()\n\nset_tsk_need_resched() tests TIF_NEED_RESCHED, calls\n__trace_set_need_resched() if the flag is clear, then sets it via\nset_tsk_thread_flag().  A BPF raw_tp program attached to\nsched_set_need_resched executes synchronously inside __bpf_trace_run().\nOn return, __bpf_trace_run() drops the RCU lock with\nrcu_read_unlock_migrate(), which on the preempt-or-BH-disabled path\ncalls set_need_resched_current() -\u003e set_tsk_need_resched() again.\n\nset_tsk_thread_flag() follows the tracepoint call, so every re-entrant\nframe sees TIF_NEED_RESCHED clear and calls __trace_set_need_resched()\nagain:\n\n  BUG: TASK stack guard page was hit at ffffc9001224ff98\n  Oops: stack guard page: 0000 [#1] SMP KASAN PTI\n  RIP: 0010:__bpf_trace_sched_set_need_resched_tp+0x1c/0x190\n  Call Trace:\n   trace_sched_set_need_resched_tp+0x110/0x130\n   set_tsk_need_resched include/linux/sched.h:2076\n   set_need_resched_current include/linux/sched.h:2094\n   rcu_read_unlock_special+0x43a/0x440\n   __rcu_read_unlock+0x9e/0x120\n   rcu_read_unlock_migrate+0xa9/0x240\n   __bpf_trace_run+0x131/0x180\n   bpf_trace_run3+0x333/0x430\n   __bpf_trace_sched_set_need_resched_tp+0x13a/0x190\n   trace_sched_set_need_resched_tp+0x110/0x130\n   set_tsk_need_resched include/linux/sched.h:2076\n   ...\n\n__resched_curr() has the same ordering, firing the tracepoint before\nsetting the flag via set_ti_thread_flag() or set_nr_and_not_polling().\nFix it for consistency.\n\nReplace the separate test_tsk_thread_flag() + set_tsk_thread_flag() pair\nin set_tsk_need_resched() with test_and_set_tsk_thread_flag().  In\n__resched_curr(), move the tracepoint call after the flag is set in\neach path.","modified":"2026-11-30T15:02:29.126957486Z","published":"2026-11-30T13:35:52.291Z","database_specific":{"cna_assigner":"Linux","osv_generated_from":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/139xxx/CVE-2026-139558.json"},"references":[{"type":"PACKAGE","url":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git"},{"type":"WEB","url":"https://git.kernel.org/stable/c/53bc5c556b82a3ca32b62ba349c4511f91526b9f"},{"type":"WEB","url":"https://git.kernel.org/stable/c/cce90cef0abc44caab7c2c5a6e775424537ffa84"},{"type":"WEB","url":"https://git.kernel.org/stable/c/d9079e8eb14188f57d6553a7433ced6875c83711"},{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/139xxx/CVE-2026-139558.json"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-139558"}],"affected":[{"ranges":[{"type":"GIT","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","events":[{"introduced":"adcc3bfa8806761ac21aa271f78454113ec6936e"},{"fixed":"cce90cef0abc44caab7c2c5a6e775424537ffa84"},{"fixed":"d9079e8eb14188f57d6553a7433ced6875c83711"},{"fixed":"53bc5c556b82a3ca32b62ba349c4511f91526b9f"}]}],"database_specific":{"source":"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2026-139558.json"}},{"package":{"name":"Kernel","ecosystem":"Linux"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"6.17.0"},{"fixed":"6.18.65"}]},{"type":"ECOSYSTEM","events":[{"introduced":"6.19.0"},{"fixed":"7.3.6"}]}],"database_specific":{"source":"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2026-139558.json"}}],"schema_version":"1.9.2"}