Advisory

UBUNTU-CVE-2021-47209

Also known as: CVE-2021-47209

Summary

The record has no summary.

Details

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---

Severity

Medium Basis: CVSS v3 score 5.5, vector CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H

Dates

Published
2024-04-10 19:15 UTC
Modified
2026-08-06 03:06 UTC

Affected packages and fixes

64 affected packages; affected: introduced 0
PackageSystemFix
linux-hwe-edgeDebian packages (deb) · Ubuntu 16.04No fixed version is listed.
linux-aws-5.0Debian packages (deb) · Ubuntu 18.04No fixed version is listed.
linux-aws-5.3Debian packages (deb) · Ubuntu 18.04No fixed version is listed.
linux-azureDebian packages (deb) · Ubuntu 18.04No fixed version is listed.
linux-azure-5.3Debian packages (deb) · Ubuntu 18.04No fixed version is listed.
linux-azure-edgeDebian packages (deb) · Ubuntu 18.04No fixed version is listed.
linux-gcpDebian packages (deb) · Ubuntu 18.04No fixed version is listed.
linux-gcp-5.3Debian packages (deb) · Ubuntu 18.04No fixed version is listed.
linux-gke-4.15Debian packages (deb) · Ubuntu 18.04No fixed version is listed.
linux-gke-5.4Debian packages (deb) · Ubuntu 18.04No fixed version is listed.
linux-gkeop-5.4Debian packages (deb) · Ubuntu 18.04No fixed version is listed.
linux-hweDebian packages (deb) · Ubuntu 18.04No fixed version is listed.
linux-hwe-edgeDebian packages (deb) · Ubuntu 18.04No fixed version is listed.
linux-oemDebian packages (deb) · Ubuntu 18.04No fixed version is listed.
linux-oracle-5.0Debian packages (deb) · Ubuntu 18.04No fixed version is listed.
linux-oracle-5.3Debian packages (deb) · Ubuntu 18.04No fixed version is listed.
linux-aws-5.11Debian packages (deb) · Ubuntu 20.04No fixed version is listed.
linux-aws-5.13Debian packages (deb) · Ubuntu 20.04No fixed version is listed.
linux-aws-5.8Debian packages (deb) · Ubuntu 20.04No fixed version is listed.
linux-azure-5.11Debian packages (deb) · Ubuntu 20.04No fixed version is listed.
linux-azure-5.13Debian packages (deb) · Ubuntu 20.04No fixed version is listed.
linux-azure-5.8Debian packages (deb) · Ubuntu 20.04No fixed version is listed.
linux-azure-fdeDebian packages (deb) · Ubuntu 20.04No fixed version is listed.
linux-gcp-5.11Debian packages (deb) · Ubuntu 20.04No fixed version is listed.
linux-gcp-5.13Debian packages (deb) · Ubuntu 20.04No fixed version is listed.
linux-gcp-5.8Debian packages (deb) · Ubuntu 20.04No fixed version is listed.
linux-gkeDebian packages (deb) · Ubuntu 20.04No fixed version is listed.
linux-gke-5.15Debian packages (deb) · Ubuntu 20.04No fixed version is listed.
linux-hwe-5.11Debian packages (deb) · Ubuntu 20.04No fixed version is listed.
linux-hwe-5.13Debian packages (deb) · Ubuntu 20.04No fixed version is listed.
linux-hwe-5.8Debian packages (deb) · Ubuntu 20.04No fixed version is listed.
linux-intel-5.13Debian packages (deb) · Ubuntu 20.04No fixed version is listed.
linux-oem-5.10Debian packages (deb) · Ubuntu 20.04No fixed version is listed.
linux-oem-5.13Debian packages (deb) · Ubuntu 20.04No fixed version is listed.
linux-oem-5.14Debian packages (deb) · Ubuntu 20.04No fixed version is listed.
linux-oem-5.6Debian packages (deb) · Ubuntu 20.04No fixed version is listed.
linux-oracle-5.11Debian packages (deb) · Ubuntu 20.04No fixed version is listed.
linux-oracle-5.13Debian packages (deb) · Ubuntu 20.04No fixed version is listed.
linux-oracle-5.8Debian packages (deb) · Ubuntu 20.04No fixed version is listed.
linux-raspi2Debian packages (deb) · Ubuntu 20.04No fixed version is listed.
linux-riscvDebian packages (deb) · Ubuntu 20.04No fixed version is listed.
linux-riscv-5.11Debian packages (deb) · Ubuntu 20.04No fixed version is listed.
linux-riscv-5.8Debian packages (deb) · Ubuntu 20.04No fixed version is listed.
linux-allwinner-5.19Debian packages (deb) · Ubuntu 22.04No fixed version is listed.
linux-aws-5.19Debian packages (deb) · Ubuntu 22.04No fixed version is listed.
linux-aws-6.2Debian packages (deb) · Ubuntu 22.04No fixed version is listed.
linux-azure-5.19Debian packages (deb) · Ubuntu 22.04No fixed version is listed.
linux-azure-6.2Debian packages (deb) · Ubuntu 22.04No fixed version is listed.
linux-azure-fde-5.19Debian packages (deb) · Ubuntu 22.04No fixed version is listed.
linux-azure-fde-6.2Debian packages (deb) · Ubuntu 22.04No fixed version is listed.
linux-gcp-5.19Debian packages (deb) · Ubuntu 22.04No fixed version is listed.
linux-gcp-6.2Debian packages (deb) · Ubuntu 22.04No fixed version is listed.
linux-hwe-5.19Debian packages (deb) · Ubuntu 22.04No fixed version is listed.
linux-hwe-6.2Debian packages (deb) · Ubuntu 22.04No fixed version is listed.
linux-lowlatency-hwe-5.19Debian packages (deb) · Ubuntu 22.04No fixed version is listed.
linux-lowlatency-hwe-6.2Debian packages (deb) · Ubuntu 22.04No fixed version is listed.
linux-nvidia-6.2Debian packages (deb) · Ubuntu 22.04No fixed version is listed.
linux-oem-5.17Debian packages (deb) · Ubuntu 22.04No fixed version is listed.
linux-oem-6.0Debian packages (deb) · Ubuntu 22.04No fixed version is listed.
linux-oem-6.1Debian packages (deb) · Ubuntu 22.04No fixed version is listed.
linux-riscvDebian packages (deb) · Ubuntu 22.04No fixed version is listed.
linux-riscv-5.19Debian packages (deb) · Ubuntu 22.04No fixed version is listed.
linux-starfive-5.19Debian packages (deb) · Ubuntu 22.04No fixed version is listed.
linux-starfive-6.2Debian packages (deb) · Ubuntu 22.04No fixed version is listed.

Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.

Check your own computer: guard packages check

View this record on OSV.dev

Source

Source: Ubuntu Security Notices · CC BY-SA 4.0

Sources & licences