Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A59216EC05 for ; Fri, 12 Jul 2024 12:33:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720787620; cv=none; b=hN0mup8V+7ULafs1+rhYUBcExzUDGJixX2mOKtoy/07/qLBJaSKcmR3FuBQC3AJ/nkT22ZHN5CqhQIqThIN0FiO0yZ7RzFZjp5m5UtEsdc6fmsDi3fu87ms0lY1WQVKjEmt69rxhxcVopcGiZ/XOMSJ3LHOljG5n8SE3k5db1fc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720787620; c=relaxed/simple; bh=Lrt9iQe2V6DXo4mozx6IfC75BFr5B05eZCkF/BZQp+k=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=GVoAbf4C2U1vztjzxUbT//dLmVDBQb/Vwk0nAoeMaaWJUEci/00Z3Yo769F6hJjVxlbdZLGJUS1V/DUqH6htnJCVKGSepbN2kD48ZtRbMQLaP7I0L2OBnp90yQLUJPn/YUPnxL/jIhpcgFgxqS7A2yXgPRuBanP4g4+VFtoLP1I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=bo8pPGw7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="bo8pPGw7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5004C32786; Fri, 12 Jul 2024 12:33:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1720787620; bh=Lrt9iQe2V6DXo4mozx6IfC75BFr5B05eZCkF/BZQp+k=; h=From:To:Cc:Subject:Date:Reply-to:From; b=bo8pPGw7OWRw75fcvwX8Sq9yMJfR40KSGmVpcJalz09z3+b71/LcV10llNQRX/r0C OhfFryEEkWmsE4sVEIOBF9+p1V5kOlfMktvwJptqjfwHakhDBuPU6EcaYtWhbwMMl2 gxhCIr6r5YXYmNh4I+oBvO/n+tSPleYxNwfa1xVg= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-40953: KVM: Fix a data race on last_boosted_vcpu in kvm_vcpu_on_spin() Date: Fri, 12 Jul 2024 14:32:29 +0200 Message-ID: <2024071223-CVE-2024-40953-8685@gregkh> X-Mailer: git-send-email 2.45.2 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=4347; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=Lrt9iQe2V6DXo4mozx6IfC75BFr5B05eZCkF/BZQp+k=; b=owGbwMvMwCRo6H6F97bub03G02pJDGkTlcIZuaQernq5Z/7pg+8y9hj+2vV6g2gln4BV5d9+x 7fL0zd5dMSyMAgyMciKKbJ82cZzdH/FIUUvQ9vTMHNYmUCGMHBxCsBElJ4yLDjZfTvGtzlrUtmX dfFu7hGs93xOXWOYH/VZ5oKUfMPBH3/9zzlvXrvVoXIjPwA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit Description =========== In the Linux kernel, the following vulnerability has been resolved: KVM: Fix a data race on last_boosted_vcpu in kvm_vcpu_on_spin() Use {READ,WRITE}_ONCE() to access kvm->last_boosted_vcpu to ensure the loads and stores are atomic. In the extremely unlikely scenario the compiler tears the stores, it's theoretically possible for KVM to attempt to get a vCPU using an out-of-bounds index, e.g. if the write is split into multiple 8-bit stores, and is paired with a 32-bit load on a VM with 257 vCPUs: CPU0 CPU1 last_boosted_vcpu = 0xff; (last_boosted_vcpu = 0x100) last_boosted_vcpu[15:8] = 0x01; i = (last_boosted_vcpu = 0x1ff) last_boosted_vcpu[7:0] = 0x00; vcpu = kvm->vcpu_array[0x1ff]; As detected by KCSAN: BUG: KCSAN: data-race in kvm_vcpu_on_spin [kvm] / kvm_vcpu_on_spin [kvm] write to 0xffffc90025a92344 of 4 bytes by task 4340 on cpu 16: kvm_vcpu_on_spin (arch/x86/kvm/../../../virt/kvm/kvm_main.c:4112) kvm handle_pause (arch/x86/kvm/vmx/vmx.c:5929) kvm_intel vmx_handle_exit (arch/x86/kvm/vmx/vmx.c:? arch/x86/kvm/vmx/vmx.c:6606) kvm_intel vcpu_run (arch/x86/kvm/x86.c:11107 arch/x86/kvm/x86.c:11211) kvm kvm_arch_vcpu_ioctl_run (arch/x86/kvm/x86.c:?) kvm kvm_vcpu_ioctl (arch/x86/kvm/../../../virt/kvm/kvm_main.c:?) kvm __se_sys_ioctl (fs/ioctl.c:52 fs/ioctl.c:904 fs/ioctl.c:890) __x64_sys_ioctl (fs/ioctl.c:890) x64_sys_call (arch/x86/entry/syscall_64.c:33) do_syscall_64 (arch/x86/entry/common.c:?) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130) read to 0xffffc90025a92344 of 4 bytes by task 4342 on cpu 4: kvm_vcpu_on_spin (arch/x86/kvm/../../../virt/kvm/kvm_main.c:4069) kvm handle_pause (arch/x86/kvm/vmx/vmx.c:5929) kvm_intel vmx_handle_exit (arch/x86/kvm/vmx/vmx.c:? arch/x86/kvm/vmx/vmx.c:6606) kvm_intel vcpu_run (arch/x86/kvm/x86.c:11107 arch/x86/kvm/x86.c:11211) kvm kvm_arch_vcpu_ioctl_run (arch/x86/kvm/x86.c:?) kvm kvm_vcpu_ioctl (arch/x86/kvm/../../../virt/kvm/kvm_main.c:?) kvm __se_sys_ioctl (fs/ioctl.c:52 fs/ioctl.c:904 fs/ioctl.c:890) __x64_sys_ioctl (fs/ioctl.c:890) x64_sys_call (arch/x86/entry/syscall_64.c:33) do_syscall_64 (arch/x86/entry/common.c:?) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130) value changed: 0x00000012 -> 0x00000000 The Linux kernel CVE team has assigned CVE-2024-40953 to this issue. Affected and fixed versions =========================== Issue introduced in 2.6.39 with commit 217ece6129f2 and fixed in 6.1.96 with commit 92c77807d938 Issue introduced in 2.6.39 with commit 217ece6129f2 and fixed in 6.6.36 with commit a937ef951bba Issue introduced in 2.6.39 with commit 217ece6129f2 and fixed in 6.9.7 with commit 95c8dd79f3a1 Issue introduced in 2.6.39 with commit 217ece6129f2 and fixed in 6.10-rc5 with commit 49f683b41f28 Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2024-40953 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: virt/kvm/kvm_main.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/92c77807d938145c7c3350c944ef9f39d7f6017c https://git.kernel.org/stable/c/a937ef951bba72f48d2402451419d725d70dba20 https://git.kernel.org/stable/c/95c8dd79f3a14df96b3820b35b8399bd91b2be60 https://git.kernel.org/stable/c/49f683b41f28918df3e51ddc0d928cb2e934ccdb