CVE-2021-47209sched/fair: Prevent dead task groups from regaining cfs_rq's
In the Linux kernel, the following vulnerability has been resolved: sched/fair: Prevent dead task groups from regaining cfs_rq's Kevin is reporting crashes which point to a use-after-free of a cfs_rq in update_blocked_averages(). Initial debugging revealed that we've live cfs_rq's (on_list=1) in an about to be kfree()'d task group in free_fair_sched_group(). However, it was unclear how that can happen. His kernel config happened to lead to a layout of struct sched_entity that put the 'my_q' member directly into the middle of the object which makes it incidentally overlap with SLUB's freelist pointer. That, in combination with SLAB_FREELIST_HARDENED's freelist pointer mangling, leads to a reliable access violation in form of a #GP which made the UAF fail fast. Michal seems to have run into the same issue[1]. He already correctly diagnosed that commit a7b359fc6a37 ("sched/fair: Correctly insert cfs_rq's to list on unthrottle") is causing the preconditions for the UAF to happen by re-adding cfs_rq's also to task groups that have no more running tasks, i.e. also to dead ones. His analysis, however, misses the real root cause and it cannot be seen from the crash backtrace only, as the real offender is tg_unthrottle_up() getting called via sched_cfs_period_timer() via the timer interrupt at an inconvenient time. When unregister_fair_sched_group() unlinks all cfs_rq's from the dying task group, it doesn't protect itself from getting interrupted. If the timer interrupt triggers while we iterate over all CPUs or after unregister_fair_sched_group() has finished but prior to unlinking the task group, sched_cfs_period_timer() will execute and walk the list of task groups, trying to unthrottle cfs_rq's, i.e. re-add them to the dying task group. These will later -- in free_fair_sched_group() -- be kfree()'ed while still being linked, leading to the fireworks Kevin and Michal are seeing. To fix this race, ensure the dying task group gets unlinked first. However, simply switching the order of unregistering and unlinking the task group isn't sufficient, as concurrent RCU walkers might still see it, as can be seen below: CPU1: CPU2: : timer IRQ: : do_sched_cfs_period_timer(): : : : distribute_cfs_runtime(): : rcu_read_lock(); : : : unthrottle_cfs_rq(): sched_offline_group(): : : walk_tg_tree_from(…,tg_unthrottle_up,…): list_del_rcu(&tg->list); : (1) : list_for_each_entry_rcu(child, &parent->children, siblings) : : (2) list_del_rcu(&tg->siblings); : : tg_unthrottle_up(): unregister_fair_sched_group(): struct cfs_rq *cfs_rq = tg->cfs_rq[cpu_of(rq)]; : : list_del_leaf_cfs_rq(tg->cfs_rq[cpu]); : : : : if (!cfs_rq_is_decayed(cfs_rq) || cfs_rq->nr_running) (3) : list_add_leaf_cfs_rq(cfs_rq); : : : : : : : : : ---truncated---
What to do
Fixed builds are available from Debian: see the table below for the fixed version per release.
Ubuntu has not shipped a fix for every release yet.
Is your server affected? One read-only command checks every installed package against this CVE and all others, using each vendor's fixed versions. Get started or get a free API key.
curl -sS "https://api.cvefocus.com/v1/check?format=text" -H "Authorization: Bearer $CVEFOCUS_KEY" \ -H "Content-Type: text/plain" --data-binary @inventory.txt
Vendor status at a glance
Status by vendor and release
From each vendor's own security data and VEX statements. "Fixed" means a fixed build is published for that release.
| Release | Package | Status | Fixed version | Advisory |
|---|---|---|---|---|
| Ubuntu 24.04 | linux | Not affected vulnerable_code_not_present | ||
| Ubuntu 24.04 | linux-aws | Not affected vulnerable_code_not_present | ||
| Ubuntu 24.04 | linux-azure | Not affected vulnerable_code_not_present | ||
| Ubuntu 24.04 | linux-azure-fde | Not affected vulnerable_code_not_present | ||
| Ubuntu 24.04 | linux-gcp | Not affected vulnerable_code_not_present | ||
| Ubuntu 24.04 | linux-gke | Not affected vulnerable_code_not_present | ||
| Ubuntu 24.04 | linux-gkeop | Not affected vulnerable_code_not_present | ||
| Ubuntu 24.04 | linux-ibm | Not affected vulnerable_code_not_present | ||
| Ubuntu 24.04 | linux-intel | Not affected vulnerable_code_not_present | ||
| Ubuntu 24.04 | linux-lowlatency | Not affected vulnerable_code_not_present | ||
| Ubuntu 24.04 | linux-nvidia | Not affected vulnerable_code_not_present | ||
| Ubuntu 24.04 | linux-nvidia-lowlatency | Not affected vulnerable_code_not_present | ||
| Ubuntu 24.04 | linux-oem-6.8 | Not affected vulnerable_code_not_present | ||
| Ubuntu 24.04 | linux-oracle | Not affected vulnerable_code_not_present | ||
| Ubuntu 24.04 | linux-raspi | Not affected vulnerable_code_not_present | ||
| Ubuntu 24.04 | linux-riscv | Not affected vulnerable_code_not_present | ||
| Ubuntu 22.04 | linux | Not affected vulnerable_code_not_present | ||
| Ubuntu 22.04 | linux-allwinner-5.19 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 22.04 | linux-aws | Not affected vulnerable_code_not_present | ||
| Ubuntu 22.04 | linux-aws-5.19 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 22.04 | linux-aws-6.2 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 22.04 | linux-aws-6.5 | Not affected vulnerable_code_not_present | ||
| Ubuntu 22.04 | linux-azure | Not affected vulnerable_code_not_present | ||
| Ubuntu 22.04 | linux-azure-5.19 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 22.04 | linux-azure-6.2 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 22.04 | linux-azure-6.5 | Not affected vulnerable_code_not_present | ||
| Ubuntu 22.04 | linux-azure-fde | Not affected vulnerable_code_not_present | ||
| Ubuntu 22.04 | linux-azure-fde-5.19 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 22.04 | linux-azure-fde-6.2 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 22.04 | linux-gcp | Not affected vulnerable_code_not_present | ||
| Ubuntu 22.04 | linux-gcp-5.19 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 22.04 | linux-gcp-6.2 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 22.04 | linux-gcp-6.5 | Not affected vulnerable_code_not_present | ||
| Ubuntu 22.04 | linux-gke | Not affected vulnerable_code_not_present | ||
| Ubuntu 22.04 | linux-gkeop | Not affected vulnerable_code_not_present | ||
| Ubuntu 22.04 | linux-hwe-5.19 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 22.04 | linux-hwe-6.2 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 22.04 | linux-hwe-6.5 | Not affected vulnerable_code_not_present | ||
| Ubuntu 22.04 | linux-ibm | Not affected vulnerable_code_not_present | ||
| Ubuntu 22.04 | linux-intel-iotg | Not affected vulnerable_code_not_present | ||
| Ubuntu 22.04 | linux-kvm | Not affected vulnerable_code_not_present | ||
| Ubuntu 22.04 | linux-lowlatency | Not affected vulnerable_code_not_present | ||
| Ubuntu 22.04 | linux-lowlatency-hwe-5.19 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 22.04 | linux-lowlatency-hwe-6.2 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 22.04 | linux-lowlatency-hwe-6.5 | Not affected vulnerable_code_not_present | ||
| Ubuntu 22.04 | linux-nvidia | Not affected vulnerable_code_not_present | ||
| Ubuntu 22.04 | linux-nvidia-6.2 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 22.04 | linux-nvidia-6.5 | Not affected vulnerable_code_not_present | ||
| Ubuntu 22.04 | linux-nvidia-6.8 | Not affected vulnerable_code_not_present | ||
| Ubuntu 22.04 | linux-oem-5.17 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 22.04 | linux-oem-6.0 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 22.04 | linux-oem-6.1 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 22.04 | linux-oem-6.5 | Not affected vulnerable_code_not_present | ||
| Ubuntu 22.04 | linux-oracle | Not affected vulnerable_code_not_present | ||
| Ubuntu 22.04 | linux-oracle-6.5 | Not affected vulnerable_code_not_present | ||
| Ubuntu 22.04 | linux-raspi | Not affected vulnerable_code_not_present | ||
| Ubuntu 22.04 | linux-riscv | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 22.04 | linux-riscv-5.19 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 22.04 | linux-riscv-6.5 | Not affected vulnerable_code_not_present | ||
| Ubuntu 22.04 | linux-starfive-5.19 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 22.04 | linux-starfive-6.2 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 22.04 | linux-starfive-6.5 | Not affected vulnerable_code_not_present | ||
| Ubuntu 22.04 | linux-xilinx-zynqmp | Not affected vulnerable_code_not_present | ||
| Ubuntu 20.04 | linux-aws-5.11 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 20.04 | linux-aws-5.13 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 20.04 | linux-aws-5.8 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 20.04 | linux-azure-5.11 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 20.04 | linux-azure-5.13 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 20.04 | linux-azure-5.8 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 20.04 | linux-azure-fde | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 20.04 | linux-gcp-5.11 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 20.04 | linux-gcp-5.13 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 20.04 | linux-gcp-5.8 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 20.04 | linux-gke | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 20.04 | linux-gke-5.15 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 20.04 | linux-gkeop | Not affected vulnerable_code_not_present | ||
| Ubuntu 20.04 | linux-gkeop-5.15 | Not affected vulnerable_code_not_present | ||
| Ubuntu 20.04 | linux-hwe-5.11 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 20.04 | linux-hwe-5.13 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 20.04 | linux-hwe-5.8 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 20.04 | linux-intel-5.13 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 20.04 | linux-oem-5.10 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 20.04 | linux-oem-5.13 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 20.04 | linux-oem-5.14 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 20.04 | linux-oem-5.6 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 20.04 | linux-oracle-5.11 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 20.04 | linux-oracle-5.13 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 20.04 | linux-oracle-5.8 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 20.04 | linux-raspi2 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 20.04 | linux-riscv | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 20.04 | linux-riscv-5.11 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 20.04 | linux-riscv-5.8 | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2021-47209 | |
| Ubuntu 18.04 | linux-aws-5.0 | Fix pending | UBUNTU-CVE-2021-47209 | |
| Ubuntu 18.04 | linux-aws-5.3 | Fix pending | UBUNTU-CVE-2021-47209 | |
| Ubuntu 18.04 | linux-azure | Fix pending | UBUNTU-CVE-2021-47209 | |
| Ubuntu 18.04 | linux-azure-5.3 | Fix pending | UBUNTU-CVE-2021-47209 | |
| Ubuntu 18.04 | linux-azure-edge | Fix pending | UBUNTU-CVE-2021-47209 | |
| Ubuntu 18.04 | linux-gcp | Fix pending | UBUNTU-CVE-2021-47209 | |
| Ubuntu 18.04 | linux-gcp-5.3 | Fix pending | UBUNTU-CVE-2021-47209 | |
| Ubuntu 18.04 | linux-gke-4.15 | Fix pending | UBUNTU-CVE-2021-47209 | |
| Ubuntu 18.04 | linux-gke-5.4 | Fix pending | UBUNTU-CVE-2021-47209 | |
| Ubuntu 18.04 | linux-gkeop-5.4 | Fix pending | UBUNTU-CVE-2021-47209 | |
| Ubuntu 18.04 | linux-hwe | Fix pending | UBUNTU-CVE-2021-47209 | |
| Ubuntu 18.04 | linux-hwe-edge | Fix pending | UBUNTU-CVE-2021-47209 | |
| Ubuntu 18.04 | linux-oem | Fix pending | UBUNTU-CVE-2021-47209 | |
| Ubuntu 18.04 | linux-oracle-5.0 | Fix pending | UBUNTU-CVE-2021-47209 | |
| Ubuntu 18.04 | linux-oracle-5.3 | Fix pending | UBUNTU-CVE-2021-47209 | |
| Ubuntu 16.04 | linux-hwe-edge | Fix pending | UBUNTU-CVE-2021-47209 | |
| Debian 14 | linux | Fixed | 5.15.5-1 | DEBIAN-CVE-2021-47209 |
| Debian 13 | linux | Fixed | 5.15.5-1 | DEBIAN-CVE-2021-47209 |
| Debian 12 | linux | Fixed | 5.15.5-1 | DEBIAN-CVE-2021-47209 |
What the vendor says
As published in the CVE record by Linux, the CVE's assigner (usually the vendor). Check the vendor's advisory before acting.
- Linux: affected: a7b359fc6a37faaf472125867c8dc5a068c90982 to before 512e21c150c1c3ee298852660f3a796e267e62ec, a7b359fc6a37faaf472125867c8dc5a068c90982 to before b027789e5e50494c2325cc70c8642e7fd6059479; fixed in
512e21c150c1c3ee298852660f3a796e267e62ec - Linux: affected: 5.13
References
- https://git.kernel.org/stable/c/512e21c150c1c3ee298852660f3a796e267e62ec
- https://git.kernel.org/stable/c/b027789e5e50494c2325cc70c8642e7fd6059479
About this page
Compiled by CVEfocus from the CVE List, the security data and VEX statements of Ubuntu, Debian, Red Hat, AlmaLinux, Rocky Linux and Microsoft, CISA's Known Exploited Vulnerabilities catalog and FIRST EPSS, refreshed several times a day (data status). Information only; see the disclaimer. Official record: cve.org · NVD.