{"id":"CVE-2026-139177","state":"PUBLISHED","title":"sched_ext: Reject rq-lock-taking kfuncs in tracing programs","description":"In the Linux kernel, the following vulnerability has been resolved:\n\nsched_ext: Reject rq-lock-taking kfuncs in tracing programs\n\nscx_bpf_cpuperf_set() and scx_bpf_cidperf_set() are members of\nscx_kfunc_ids_any, which is registered for BPF_PROG_TYPE_TRACING.\nA tracing program can run in a context which already holds the target\nrq lock, in which case scx_cpuperf_set() attempts to acquire the same\nlock again:\n\n  __schedule()\n    rq_lock(rq);                          /* rq->__lock is held */\n    trace_sched_switch();\n      BPF tracing program\n        scx_bpf_cpuperf_set(smp_processor_id(), 1024);\n          scx_cpuperf_set();\n            locked_rq = scx_locked_rq(); /* NULL */\n            rq_lock_irqsave(rq, &rf);    /* same lock */\n\nscx_locked_rq() only tracks rq locks held during SCX callback\ninvocations, so it cannot detect an rq lock held by the surrounding\nkernel code.\n\nThe deadlock can be reproduced with two BPF programs. The first is a\nminimal SCX scheduler, which only needs to be registered and enabled:\n\n  SEC(\".struct_ops.link\")\n  struct sched_ext_ops minimal_ops = {\n          .name = \"minimal\",\n  };\n\nThe second is a tracing program attached to tp_btf/sched_switch,\nwhich fires from __schedule() with rq->__lock already held:\n\n  SEC(\"tp_btf/sched_switch\")\n  int BPF_PROG(on_sched_switch, bool preempt, struct task_struct *prev,\n               struct task_struct *next, unsigned int prev_state)\n  {\n          scx_bpf_cpuperf_set(bpf_get_smp_processor_id(), 1024);\n          return 0;\n  }\n\nWith both programs attached, the next context switch on any CPU\ndeadlocks that CPU. Lockdep reports:\n\n  WARNING: possible recursive locking detected\n  7.3.0-rc7 #3 Not tainted\n  swapper/3/0 is trying to acquire lock:\n   (&rq->__lock){-.-.}-{2:2}, at: raw_spin_rq_lock_nested+0x1e/0x30\n\n  but task is already holding lock:\n   (&rq->__lock){-.-.}-{2:2}, at: __schedule+0xeb/0x1430\n\n   Possible unsafe locking scenario:\n\n         CPU0\n         ----\n    lock(&rq->__lock);\n    lock(&rq->__lock);\n\n    *** DEADLOCK ***\n\n  Call Trace:\n   <TASK>\n   print_deadlock_bug.cold+0xc0/0xd0\n   __lock_acquire+0x12fa/0x1b80\n   lock_acquire+0xd1/0x2f0\n   _raw_spin_lock_nested+0x32/0x40\n   raw_spin_rq_lock_nested+0x1e/0x30\n   scx_cpuperf_set+0x1e9/0x310\n   scx_bpf_cpuperf_set+0x9b/0x230\n   bpf_prog_..._on_sched_switch+0x3d/0x41\n   bpf_trace_run4+0x125/0x450\n   __traceiter_sched_switch+0x4b/0x70\n   __schedule+0x94a/0x1430\n   schedule_idle+0x26/0x50\n   cpu_startup_entry+0x2d/0x30\n   start_secondary+0xfc/0x100\n   </TASK>\n\nThe CPU remains locked up with interrupts disabled.\nscx_bpf_cidperf_set() is similarly affected, as it resolves the CID\nthrough scx_cid_to_cpu() before reaching the same rq-locking path.\n\nThere is no reliable way for these kfuncs to determine whether the\nsurrounding tracing context already holds an rq lock. Reject calls to\nboth kfuncs from tracing programs at verification time, while\npreserving their availability to SCX struct_ops and syscall programs.","publishedAt":"2026-11-30T13:32:17.595Z","updatedAt":"2026-11-30T13:32:17.595Z","severity":null,"assigner":"Linux","products":["Linux Linux"],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"a11d6784d7316a6c77ca9f14fb1a698ebbb3c1fb","status":"affected","lessThan":"2bf613d098ffdeef30298d9306f6ff60461d7a3f","versionType":"git"},{"version":"a11d6784d7316a6c77ca9f14fb1a698ebbb3c1fb","status":"affected","lessThan":"e62ca4fcc71482cf0e8d5ba3185498ce01864cc0","versionType":"git"},{"version":"a11d6784d7316a6c77ca9f14fb1a698ebbb3c1fb","status":"affected","lessThan":"b07a7450f6ef98c79ebd450a92fc4bb6b8f1e02e","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["kernel/sched/ext/ext.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"6.15","status":"affected"},{"version":"0","status":"unaffected","lessThan":"6.15","versionType":"semver"},{"version":"6.18.66","status":"unaffected","lessThanOrEqual":"6.18.*","versionType":"semver"},{"version":"7.3.6","status":"unaffected","lessThanOrEqual":"7.3.*","versionType":"semver"},{"version":"7.4-rc1","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["kernel/sched/ext/ext.c"]}],"references":["https://git.kernel.org/stable/c/2bf613d098ffdeef30298d9306f6ff60461d7a3f","https://git.kernel.org/stable/c/e62ca4fcc71482cf0e8d5ba3185498ce01864cc0","https://git.kernel.org/stable/c/b07a7450f6ef98c79ebd450a92fc4bb6b8f1e02e"],"weaknesses":[],"ingestedAt":"2026-11-30T13:44:05.999Z","source":{"repository":"CVEProject/cvelistV5","path":"cves/2026/139xxx/CVE-2026-139177.json","commit":"8c2c22940a0de21d18737df980299c0488d5dc73","baselineCommit":"556c9d3a8cd17e218bb8e452ba7cd619a384ff47"},"raw":{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2026-139177","state":"PUBLISHED","datePublished":"2026-11-30T13:32:17.595Z","dateUpdated":"2026-11-30T13:32:17.595Z","assignerShortName":"Linux","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateReserved":"2026-11-30T13:22:15.918Z"},"containers":{"cna":{"title":"sched_ext: Reject rq-lock-taking kfuncs in tracing programs","descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\nsched_ext: Reject rq-lock-taking kfuncs in tracing programs\n\nscx_bpf_cpuperf_set() and scx_bpf_cidperf_set() are members of\nscx_kfunc_ids_any, which is registered for BPF_PROG_TYPE_TRACING.\nA tracing program can run in a context which already holds the target\nrq lock, in which case scx_cpuperf_set() attempts to acquire the same\nlock again:\n\n  __schedule()\n    rq_lock(rq);                          /* rq->__lock is held */\n    trace_sched_switch();\n      BPF tracing program\n        scx_bpf_cpuperf_set(smp_processor_id(), 1024);\n          scx_cpuperf_set();\n            locked_rq = scx_locked_rq(); /* NULL */\n            rq_lock_irqsave(rq, &rf);    /* same lock */\n\nscx_locked_rq() only tracks rq locks held during SCX callback\ninvocations, so it cannot detect an rq lock held by the surrounding\nkernel code.\n\nThe deadlock can be reproduced with two BPF programs. The first is a\nminimal SCX scheduler, which only needs to be registered and enabled:\n\n  SEC(\".struct_ops.link\")\n  struct sched_ext_ops minimal_ops = {\n          .name = \"minimal\",\n  };\n\nThe second is a tracing program attached to tp_btf/sched_switch,\nwhich fires from __schedule() with rq->__lock already held:\n\n  SEC(\"tp_btf/sched_switch\")\n  int BPF_PROG(on_sched_switch, bool preempt, struct task_struct *prev,\n               struct task_struct *next, unsigned int prev_state)\n  {\n          scx_bpf_cpuperf_set(bpf_get_smp_processor_id(), 1024);\n          return 0;\n  }\n\nWith both programs attached, the next context switch on any CPU\ndeadlocks that CPU. Lockdep reports:\n\n  WARNING: possible recursive locking detected\n  7.3.0-rc7 #3 Not tainted\n  swapper/3/0 is trying to acquire lock:\n   (&rq->__lock){-.-.}-{2:2}, at: raw_spin_rq_lock_nested+0x1e/0x30\n\n  but task is already holding lock:\n   (&rq->__lock){-.-.}-{2:2}, at: __schedule+0xeb/0x1430\n\n   Possible unsafe locking scenario:\n\n         CPU0\n         ----\n    lock(&rq->__lock);\n    lock(&rq->__lock);\n\n    *** DEADLOCK ***\n\n  Call Trace:\n   <TASK>\n   print_deadlock_bug.cold+0xc0/0xd0\n   __lock_acquire+0x12fa/0x1b80\n   lock_acquire+0xd1/0x2f0\n   _raw_spin_lock_nested+0x32/0x40\n   raw_spin_rq_lock_nested+0x1e/0x30\n   scx_cpuperf_set+0x1e9/0x310\n   scx_bpf_cpuperf_set+0x9b/0x230\n   bpf_prog_..._on_sched_switch+0x3d/0x41\n   bpf_trace_run4+0x125/0x450\n   __traceiter_sched_switch+0x4b/0x70\n   __schedule+0x94a/0x1430\n   schedule_idle+0x26/0x50\n   cpu_startup_entry+0x2d/0x30\n   start_secondary+0xfc/0x100\n   </TASK>\n\nThe CPU remains locked up with interrupts disabled.\nscx_bpf_cidperf_set() is similarly affected, as it resolves the CID\nthrough scx_cid_to_cpu() before reaching the same rq-locking path.\n\nThere is no reliable way for these kfuncs to determine whether the\nsurrounding tracing context already holds an rq lock. Reject calls to\nboth kfuncs from tracing programs at verification time, while\npreserving their availability to SCX struct_ops and syscall programs."}],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"a11d6784d7316a6c77ca9f14fb1a698ebbb3c1fb","status":"affected","lessThan":"2bf613d098ffdeef30298d9306f6ff60461d7a3f","versionType":"git"},{"version":"a11d6784d7316a6c77ca9f14fb1a698ebbb3c1fb","status":"affected","lessThan":"e62ca4fcc71482cf0e8d5ba3185498ce01864cc0","versionType":"git"},{"version":"a11d6784d7316a6c77ca9f14fb1a698ebbb3c1fb","status":"affected","lessThan":"b07a7450f6ef98c79ebd450a92fc4bb6b8f1e02e","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["kernel/sched/ext/ext.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"6.15","status":"affected"},{"version":"0","status":"unaffected","lessThan":"6.15","versionType":"semver"},{"version":"6.18.66","status":"unaffected","lessThanOrEqual":"6.18.*","versionType":"semver"},{"version":"7.3.6","status":"unaffected","lessThanOrEqual":"7.3.*","versionType":"semver"},{"version":"7.4-rc1","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["kernel/sched/ext/ext.c"]}],"references":[{"url":"https://git.kernel.org/stable/c/2bf613d098ffdeef30298d9306f6ff60461d7a3f"},{"url":"https://git.kernel.org/stable/c/e62ca4fcc71482cf0e8d5ba3185498ce01864cc0"},{"url":"https://git.kernel.org/stable/c/b07a7450f6ef98c79ebd450a92fc4bb6b8f1e02e"}],"providerMetadata":{"shortName":"Linux","orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateUpdated":"2026-11-30T13:32:17.595Z"},"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.15","versionEndExcluding":"6.18.66"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.15","versionEndExcluding":"7.3.6"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.15","versionEndExcluding":"7.4-rc1"}]}]}],"x_generator":{"engine":"bippy-1.2.0"}}}}}