sched/core: Fix cpuset_mutex double unlock in __sched_setscheduler()
Summary
| CVE | CVE-2026-143086 |
|---|---|
| State | PUBLISHED |
| Assigner | Linux |
| Source Priority | CVE Program / NVD first with legacy fallback |
| Published | 2026-12-03 10:17:39 UTC |
| Updated | 2026-12-03 10:17:39 UTC |
| Description | In the Linux kernel, the following vulnerability has been resolved: sched/core: Fix cpuset_mutex double unlock in __sched_setscheduler() A sched_setattr() with SCHED_FLAG_KEEP_POLICY on a SCHED_DEADLINE task unlocks cpuset_mutex twice if the task's policy changes concurrently: WARNING: bad unlock balance detected! 7.4.0-rc1 #1 Not tainted ------------------------------------- repro/126 is trying to release lock (cpuset_mutex) at: [<ffffffff9a17cacc>] __sched_setscheduler+0x9cc/0xc40 but there are no more locks to release! ... Call Trace: print_unlock_imbalance_bug.part.0+0xfb/0x110 lock_release+0x286/0x2e0 __mutex_unlock_slowpath+0x1a/0x400 __sched_setscheduler+0x9cc/0xc40 __x64_sys_sched_setattr+0xa3/0x1b0 do_syscall_64+0x106/0x5f0 entry_SYSCALL_64_after_hwframe+0x77/0x7f __sched_setscheduler() samples p->policy before taking any lock, and restarts from the recheck label if p->policy differs under the rq lock. The restart drops cpuset_mutex but leaves cpuset_locked set, so a pass that no longer needs the mutex still unlocks it on its way out: CPU 1 CPU 2 __sched_setscheduler(KEEP_POLICY) policy = p->policy /* DEADLINE */ __sched_setscheduler(SCHED_OTHER) p->policy = SCHED_OTHER cpuset_locked = true cpuset_lock() rq = task_rq_lock(p) oldpolicy != p->policy cpuset_unlock() goto recheck /* no cpuset_lock() this time */ ... if (cpuset_locked) cpuset_unlock() Without CONFIG_DEBUG_MUTEXES, or CONFIG_DEBUG_RT_MUTEXES on PREEMPT_RT, nothing warns. The second unlock still clears the owner field regardless of who holds the mutex, so another task can lose cpuset_mutex inside its critical section. Entering SCHED_DEADLINE needs CAP_SYS_NICE, but a racing caller that owns the task does not need it if it samples a policy other than SCHED_DEADLINE. Clear cpuset_locked when dropping the mutex for the restart. This should be safe because the flag is only tested on the paths leaving the next pass, after that pass has set it again if it took the mutex. The following program, run as root, reproduces the splat, which no longer appears with this applied. On PREEMPT_RT it crashes the kernel within seconds, which this also fixes: #define _GNU_SOURCE #include <pthread.h> #include <stdint.h> #include <sys/syscall.h> #include <unistd.h> struct attr { uint32_t size, policy; uint64_t flags; int32_t nice; uint32_t prio; uint64_t runtime, deadline, period; }; static volatile int stop; static volatile pid_t target; static void set(struct attr a) { a.size = sizeof(a); syscall(SYS_sched_setattr, target, &a, 0); } static void *sleeper(void *arg) { target = syscall(SYS_gettid); while (!stop) usleep(1000); return arg; } static void *switcher(void *arg) { while (!stop) { /* SCHED_DEADLINE, 2us every 1s */ set((struct attr){ .policy = 6, .runtime = 2000, .deadline = 1000000000, .period = 1000000000 }); set((struct attr){ .policy = 0 }); /* SCHED_OTHER */ } return arg; } static void *racer(void *arg) { /* KEEP_POLICY | KEEP_PARAMS */ while (!stop) set((struct attr){ .flags = 0x18 }); return arg; } int main(void) { pthread_t t[5]; int i; pthread_create(&t[0], NULL, sleeper, NULL); while (!target) usleep(100); pthread_create(&t[1], NULL, switcher, NULL); for (i = 2; i < 5; i++) pthread_create(&t[i], NULL, racer, NULL); sleep(30); stop = 1; for (i = 0; i < 5; i++) pthread_join(t[i], NULL); return 0; } An LLM helped find the PREEMPT_RT crash and write this patch and its test. |
Risk And Classification
EPSS: 0.002090000 probability, percentile 0.116450000 (date 2026-12-03)
Vendor Declared Affected Products
| Source | Vendor | Product | Version | Platforms |
|---|---|---|---|---|
| CNA | Linux | Linux | affected 111cd11bbc54850f24191c52ff217da88a5e639b 1a681de657bddffbd43d88a592525362404c6e3d git | Not specified |
| CNA | Linux | Linux | affected 111cd11bbc54850f24191c52ff217da88a5e639b a87f48135265857af4ae9423963c873292310064 git | Not specified |
| CNA | Linux | Linux | affected 111cd11bbc54850f24191c52ff217da88a5e639b cc587b7f9a44b46ba2d531642fb7c3dae72ebfc0 git | Not specified |
| CNA | Linux | Linux | affected 111cd11bbc54850f24191c52ff217da88a5e639b f7141257dd67d4936f906a6cfd1d0007721f6898 git | Not specified |
| CNA | Linux | Linux | affected b950133d9a73fbd502baea12369ccb99d6446c60 git | Not specified |
| CNA | Linux | Linux | affected d0eb4917f4d36f106e2c5daa9598f6f8bd08a734 git | Not specified |
| CNA | Linux | Linux | affected 9bcfe1527882deac71d367ea1ff59d38c0fe9486 git | Not specified |
| CNA | Linux | Linux | affected 00f3719c85bf78412c9e6d9178099df5dd76634b git | Not specified |
| CNA | Linux | Linux | affected 5.10.193 5.11 semver | Not specified |
| CNA | Linux | Linux | affected 5.15.129 5.16 semver | Not specified |
| CNA | Linux | Linux | affected 6.1.50 6.2 semver | Not specified |
| CNA | Linux | Linux | affected 6.4.13 6.5 semver | Not specified |
| CNA | Linux | Linux | affected 6.5 | Not specified |
| CNA | Linux | Linux | unaffected 6.5 semver | Not specified |
| CNA | Linux | Linux | unaffected 6.12.120 6.12.* semver | Not specified |
| CNA | Linux | Linux | unaffected 6.18.66 6.18.* semver | Not specified |
| CNA | Linux | Linux | unaffected 7.3.7 7.3.* semver | Not specified |
| CNA | Linux | Linux | unaffected 7.4-rc3 * original_commit_for_fix | Not specified |
References
| Reference | Source | Link | Tags |
|---|---|---|---|
| git.kernel.org/stable/c/1a681de657bddffbd43d88a592525362404c6e3d | 416baaa9-dc9f-4396-8d5f-8c081fb06d67 | git.kernel.org | |
| git.kernel.org/stable/c/a87f48135265857af4ae9423963c873292310064 | 416baaa9-dc9f-4396-8d5f-8c081fb06d67 | git.kernel.org | |
| git.kernel.org/stable/c/cc587b7f9a44b46ba2d531642fb7c3dae72ebfc0 | 416baaa9-dc9f-4396-8d5f-8c081fb06d67 | git.kernel.org | |
| git.kernel.org/stable/c/f7141257dd67d4936f906a6cfd1d0007721f6898 | 416baaa9-dc9f-4396-8d5f-8c081fb06d67 | git.kernel.org | |
| CVE Program record | CVE.ORG | www.cve.org | canonical |
| NVD vulnerability detail | NVD | nvd.nist.gov | canonical, analysis |
No vendor comments have been submitted for this CVE.
There are currently no legacy QID mappings associated with this CVE.