{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2021-47209","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","state":"PUBLISHED","assignerShortName":"Linux","dateReserved":"2024-04-10T18:59:19.526Z","datePublished":"2024-04-10T19:01:51.363Z","dateUpdated":"2026-08-05T08:46:44.525Z"},"containers":{"cna":{"providerMetadata":{"orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","shortName":"Linux","dateUpdated":"2026-08-05T08:46:44.525Z"},"descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\nsched/fair: Prevent dead task groups from regaining cfs_rq's\n\nKevin is reporting crashes which point to a use-after-free of a cfs_rq\nin update_blocked_averages(). Initial debugging revealed that we've\nlive cfs_rq's (on_list=1) in an about to be kfree()'d task group in\nfree_fair_sched_group(). However, it was unclear how that can happen.\n\nHis kernel config happened to lead to a layout of struct sched_entity\nthat put the 'my_q' member directly into the middle of the object\nwhich makes it incidentally overlap with SLUB's freelist pointer.\nThat, in combination with SLAB_FREELIST_HARDENED's freelist pointer\nmangling, leads to a reliable access violation in form of a #GP which\nmade the UAF fail fast.\n\nMichal seems to have run into the same issue[1]. He already correctly\ndiagnosed that commit a7b359fc6a37 (\"sched/fair: Correctly insert\ncfs_rq's to list on unthrottle\") is causing the preconditions for the\nUAF to happen by re-adding cfs_rq's also to task groups that have no\nmore running tasks, i.e. also to dead ones. His analysis, however,\nmisses the real root cause and it cannot be seen from the crash\nbacktrace only, as the real offender is tg_unthrottle_up() getting\ncalled via sched_cfs_period_timer() via the timer interrupt at an\ninconvenient time.\n\nWhen unregister_fair_sched_group() unlinks all cfs_rq's from the dying\ntask group, it doesn't protect itself from getting interrupted. If the\ntimer interrupt triggers while we iterate over all CPUs or after\nunregister_fair_sched_group() has finished but prior to unlinking the\ntask group, sched_cfs_period_timer() will execute and walk the list of\ntask groups, trying to unthrottle cfs_rq's, i.e. re-add them to the\ndying task group. These will later -- in free_fair_sched_group() -- be\nkfree()'ed while still being linked, leading to the fireworks Kevin\nand Michal are seeing.\n\nTo fix this race, ensure the dying task group gets unlinked first.\nHowever, simply switching the order of unregistering and unlinking the\ntask group isn't sufficient, as concurrent RCU walkers might still see\nit, as can be seen below:\n\n    CPU1:                                      CPU2:\n      :                                        timer IRQ:\n      :                                          do_sched_cfs_period_timer():\n      :                                            :\n      :                                            distribute_cfs_runtime():\n      :                                              rcu_read_lock();\n      :                                              :\n      :                                              unthrottle_cfs_rq():\n    sched_offline_group():                             :\n      :                                                walk_tg_tree_from(…,tg_unthrottle_up,…):\n      list_del_rcu(&tg->list);                           :\n (1)  :                                                  list_for_each_entry_rcu(child, &parent->children, siblings)\n      :                                                    :\n (2)  list_del_rcu(&tg->siblings);                         :\n      :                                                    tg_unthrottle_up():\n      unregister_fair_sched_group():                         struct cfs_rq *cfs_rq = tg->cfs_rq[cpu_of(rq)];\n        :                                                    :\n        list_del_leaf_cfs_rq(tg->cfs_rq[cpu]);               :\n        :                                                    :\n        :                                                    if (!cfs_rq_is_decayed(cfs_rq) || cfs_rq->nr_running)\n (3)    :                                                        list_add_leaf_cfs_rq(cfs_rq);\n      :                                                      :\n      :                                                    :\n      :                                                  :\n      :                                                :\n      :                           \n---truncated---"}],"metrics":[{"cvssV3_1":{"version":"3.1","vectorString":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","baseScore":7.8,"baseSeverity":"HIGH"},"scenarios":[{"lang":"en","value":"AV:L - Exploitation requires local operations on the cpu cgroup hierarchy (mkdir/rmdir and related cgroup filesystem writes) to destroy a task_group while CFS bandwidth unthrottle runs; it is not reachable via network packets or adjacent-link protocols.\nAC:L - The attacker controls both sides of the race by creating/destroying cpu cgroups under a bandwidth-limited hierarchy and can tune cpu.cfs_period/cpu.max so the period timer fires during teardown; the public reproducer triggered within minutes.\nPR:L - An unprivileged user in a delegated cgroup subtree (typical containers/cloud CPU-limited workloads, systemd Delegate=) can create and remove nested cpu cgroups; real init-namespace root is not required.\nUI:N - The attacker triggers destruction and bandwidth activity themselves; no separate victim action is needed.\nS:U - Impact is confined to the host kernel scheduler/cgroup authority (local privilege escalation/DoS), with no VM, IOMMU, or other security-authority boundary crossed.\nC:H - Freed cfs_rq objects remain on the leaf_cfs_rq list and are later walked/read by update_blocked_averages()/__update_blocked_fair(); this UAF can be reclaimed and leveraged for arbitrary kernel memory disclosure.\nI:H - The same linked-list UAF yields attacker-controlled reads/writes of reclaimable cfs_rq/sched_entity memory during scheduler list walks, enabling corruption and control-flow hijacking primitives.\nA:H - The UAF reliably causes kernel oops/panic (#GP under freelist hardening, or crash via corrupted list walks), producing a full availability loss."}]}],"affected":[{"product":"Linux","vendor":"Linux","defaultStatus":"unaffected","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["kernel/sched/autogroup.c","kernel/sched/core.c","kernel/sched/fair.c","kernel/sched/rt.c","kernel/sched/sched.h"],"versions":[{"version":"a7b359fc6a37faaf472125867c8dc5a068c90982","lessThan":"512e21c150c1c3ee298852660f3a796e267e62ec","status":"affected","versionType":"git"},{"version":"a7b359fc6a37faaf472125867c8dc5a068c90982","lessThan":"b027789e5e50494c2325cc70c8642e7fd6059479","status":"affected","versionType":"git"}]},{"product":"Linux","vendor":"Linux","defaultStatus":"affected","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["kernel/sched/autogroup.c","kernel/sched/core.c","kernel/sched/fair.c","kernel/sched/rt.c","kernel/sched/sched.h"],"versions":[{"version":"5.13","status":"affected"},{"version":"0","lessThan":"5.13","status":"unaffected","versionType":"semver"},{"version":"5.15.5","lessThanOrEqual":"5.15.*","status":"unaffected","versionType":"semver"},{"version":"5.16","lessThanOrEqual":"*","status":"unaffected","versionType":"original_commit_for_fix"}]}],"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.13","versionEndExcluding":"5.15.5"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.13","versionEndExcluding":"5.16"}]}]}],"references":[{"url":"https://git.kernel.org/stable/c/512e21c150c1c3ee298852660f3a796e267e62ec"},{"url":"https://git.kernel.org/stable/c/b027789e5e50494c2325cc70c8642e7fd6059479"}],"title":"sched/fair: Prevent dead task groups from regaining cfs_rq's","x_generator":{"engine":"bippy-1.2.0"}},"adp":[{"title":"CISA ADP Vulnrichment","metrics":[{"other":{"type":"ssvc","content":{"id":"CVE-2021-47209","role":"CISA Coordinator","options":[{"Exploitation":"none"},{"Automatable":"no"},{"Technical Impact":"partial"}],"version":"2.0.3","timestamp":"2024-04-10T19:45:03.652350Z"}}}],"providerMetadata":{"orgId":"134c704f-9b21-4f2e-91b3-4a467353bcc0","shortName":"CISA-ADP","dateUpdated":"2024-06-04T17:13:26.586Z"}},{"providerMetadata":{"orgId":"af854a3a-2127-422b-91ae-364da2661108","shortName":"CVE","dateUpdated":"2024-08-04T05:32:07.493Z"},"title":"CVE Program Container","references":[{"url":"https://git.kernel.org/stable/c/512e21c150c1c3ee298852660f3a796e267e62ec","tags":["x_transferred"]},{"url":"https://git.kernel.org/stable/c/b027789e5e50494c2325cc70c8642e7fd6059479","tags":["x_transferred"]}]}]}}