{
  "threat_severity" : "Moderate",
  "public_date" : "2024-05-01T00:00:00Z",
  "bugzilla" : {
    "description" : "kernel: KVM: Always flush async #PF workqueue when vCPU is being destroyed",
    "id" : "2278350",
    "url" : "https://bugzilla.redhat.com/show_bug.cgi?id=2278350"
  },
  "cvss3" : {
    "cvss3_base_score" : "5.5",
    "cvss3_scoring_vector" : "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H",
    "status" : "verified"
  },
  "details" : [ "In the Linux kernel, the following vulnerability has been resolved:\nKVM: Always flush async #PF workqueue when vCPU is being destroyed\nAlways flush the per-vCPU async #PF workqueue when a vCPU is clearing its\ncompletion queue, e.g. when a VM and all its vCPUs is being destroyed.\nKVM must ensure that none of its workqueue callbacks is running when the\nlast reference to the KVM _module_ is put.  Gifting a reference to the\nassociated VM prevents the workqueue callback from dereferencing freed\nvCPU/VM memory, but does not prevent the KVM module from being unloaded\nbefore the callback completes.\nDrop the misguided VM refcount gifting, as calling kvm_put_kvm() from\nasync_pf_execute() if kvm_put_kvm() flushes the async #PF workqueue will\nresult in deadlock.  async_pf_execute() can't return until kvm_put_kvm()\nfinishes, and kvm_put_kvm() can't return until async_pf_execute() finishes:\nWARNING: CPU: 8 PID: 251 at virt/kvm/kvm_main.c:1435 kvm_put_kvm+0x2d/0x320 [kvm]\nModules linked in: vhost_net vhost vhost_iotlb tap kvm_intel kvm irqbypass\nCPU: 8 PID: 251 Comm: kworker/8:1 Tainted: G        W          6.6.0-rc1-e7af8d17224a-x86/gmem-vm #119\nHardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015\nWorkqueue: events async_pf_execute [kvm]\nRIP: 0010:kvm_put_kvm+0x2d/0x320 [kvm]\nCall Trace:\n<TASK>\nasync_pf_execute+0x198/0x260 [kvm]\nprocess_one_work+0x145/0x2d0\nworker_thread+0x27e/0x3a0\nkthread+0xba/0xe0\nret_from_fork+0x2d/0x50\nret_from_fork_asm+0x11/0x20\n</TASK>\n---[ end trace 0000000000000000 ]---\nINFO: task kworker/8:1:251 blocked for more than 120 seconds.\nTainted: G        W          6.6.0-rc1-e7af8d17224a-x86/gmem-vm #119\n\"echo 0 > /proc/sys/kernel/hung_task_timeout_secs\" disables this message.\ntask:kworker/8:1     state:D stack:0     pid:251   ppid:2      flags:0x00004000\nWorkqueue: events async_pf_execute [kvm]\nCall Trace:\n<TASK>\n__schedule+0x33f/0xa40\nschedule+0x53/0xc0\nschedule_timeout+0x12a/0x140\n__wait_for_common+0x8d/0x1d0\n__flush_work.isra.0+0x19f/0x2c0\nkvm_clear_async_pf_completion_queue+0x129/0x190 [kvm]\nkvm_arch_destroy_vm+0x78/0x1b0 [kvm]\nkvm_put_kvm+0x1c1/0x320 [kvm]\nasync_pf_execute+0x198/0x260 [kvm]\nprocess_one_work+0x145/0x2d0\nworker_thread+0x27e/0x3a0\nkthread+0xba/0xe0\nret_from_fork+0x2d/0x50\nret_from_fork_asm+0x11/0x20\n</TASK>\nIf kvm_clear_async_pf_completion_queue() actually flushes the workqueue,\nthen there's no need to gift async_pf_execute() a reference because all\ninvocations of async_pf_execute() will be forced to complete before the\nvCPU and its VM are destroyed/freed.  And that in turn fixes the module\nunloading bug as __fput() won't do module_put() on the last vCPU reference\nuntil the vCPU has been freed, e.g. if closing the vCPU file also puts the\nlast reference to the KVM module.\nNote that kvm_check_async_pf_completion() may also take the work item off\nthe completion queue and so also needs to flush the work queue, as the\nwork will not be seen by kvm_clear_async_pf_completion_queue().  Waiting\non the workqueue could theoretically delay a vCPU due to waiting for the\nwork to complete, but that's a very, very small chance, and likely a very\nsmall delay.  kvm_arch_async_page_present_queued() unconditionally makes a\nnew request, i.e. will effectively delay entering the guest, so the\nremaining work is really just:\ntrace_kvm_async_pf_completed(addr, cr2_or_gpa);\n__kvm_vcpu_wake_up(vcpu);\nmmput(mm);\nand mmput() can't drop the last reference to the page tables if the vCPU is\nstill alive, i.e. the vCPU won't get stuck tearing down page tables.\nAdd a helper to do the flushing, specifically to deal with \"wakeup all\"\nwork items, as they aren't actually work items, i.e. are never placed in a\nworkqueue.  Trying to flush a bogus workqueue entry rightly makes\n__flush_work() complain (kudos to whoever added that sanity check).\nNote, commit 5f6de5cbebee (\"KVM: Prevent module exit until al\n---truncated---" ],
  "affected_release" : [ {
    "product_name" : "Red Hat Enterprise Linux 8",
    "release_date" : "2024-11-05T00:00:00Z",
    "advisory" : "RHSA-2024:8870",
    "cpe" : "cpe:/a:redhat:enterprise_linux:8::nfv",
    "package" : "kernel-rt-0:4.18.0-553.27.1.rt7.368.el8_10"
  }, {
    "product_name" : "Red Hat Enterprise Linux 8",
    "release_date" : "2024-11-05T00:00:00Z",
    "advisory" : "RHSA-2024:8856",
    "cpe" : "cpe:/o:redhat:enterprise_linux:8",
    "package" : "kernel-0:4.18.0-553.27.1.el8_10"
  }, {
    "product_name" : "Red Hat Enterprise Linux 9",
    "release_date" : "2024-11-12T00:00:00Z",
    "advisory" : "RHSA-2024:9315",
    "cpe" : "cpe:/a:redhat:enterprise_linux:9",
    "package" : "kernel-0:5.14.0-503.11.1.el9_5"
  }, {
    "product_name" : "Red Hat Enterprise Linux 9",
    "release_date" : "2024-11-12T00:00:00Z",
    "advisory" : "RHSA-2024:9315",
    "cpe" : "cpe:/o:redhat:enterprise_linux:9",
    "package" : "kernel-0:5.14.0-503.11.1.el9_5"
  }, {
    "product_name" : "Red Hat Enterprise Linux 9.4 Extended Update Support",
    "release_date" : "2025-04-02T00:00:00Z",
    "advisory" : "RHSA-2025:3510",
    "cpe" : "cpe:/a:redhat:rhel_eus:9.4",
    "package" : "kernel-0:5.14.0-427.62.1.el9_4"
  } ],
  "package_state" : [ {
    "product_name" : "Red Hat Enterprise Linux 6",
    "fix_state" : "Out of support scope",
    "package_name" : "kernel",
    "cpe" : "cpe:/o:redhat:enterprise_linux:6"
  }, {
    "product_name" : "Red Hat Enterprise Linux 7",
    "fix_state" : "Out of support scope",
    "package_name" : "kernel",
    "cpe" : "cpe:/o:redhat:enterprise_linux:7"
  }, {
    "product_name" : "Red Hat Enterprise Linux 7",
    "fix_state" : "Out of support scope",
    "package_name" : "kernel-rt",
    "cpe" : "cpe:/o:redhat:enterprise_linux:7"
  }, {
    "product_name" : "Red Hat Enterprise Linux 9",
    "fix_state" : "Will not fix",
    "package_name" : "kernel-rt",
    "cpe" : "cpe:/o:redhat:enterprise_linux:9"
  } ],
  "references" : [ "https://www.cve.org/CVERecord?id=CVE-2024-26976\nhttps://nvd.nist.gov/vuln/detail/CVE-2024-26976\nhttps://lore.kernel.org/linux-cve-announce/2024050133-CVE-2024-26976-60d4@gregkh/T" ],
  "name" : "CVE-2024-26976",
  "csaw" : false
}