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 1F96230EF9F for ; Tue, 28 Oct 2025 11:52:10 +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=1761652330; cv=none; b=KV51oKXYijUpvn/Y27aIEMqRgl8aTO+9Yhm32412t+ZcbPtVJfMlOjAr4ctVg2VbjmKJlqKTGpXoDFSGwvz3jLCLV3fLL03z9Lgw6uHMDZ4AdF9ib6eBI+hHCl3Jq/zfmlRorQmOsttKwWOnEvHDEG+f8d+yRh06N9MOzTqiRH4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761652330; c=relaxed/simple; bh=DwlhjHoMop499Dnm7S9clqxEbL1Rl0lz8m+TKGlPB8U=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=lHQRJ9tmyZxb+j5Ppp9pdF7nK1ajVZACKmRyfUc/Gu2BfNItWTWRGQJOUIFNExXzG/vltImh4pcfyRZd4/i3tO75GYbc6eBUJkpMH5Q2bP6fIzWJQKOZ6AoFX+GdYmyWnuI5QC00R8zxIWWTMq9sSxv0APRErJoSuLAenLL92s8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=lKdf+1ZJ; 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="lKdf+1ZJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58D9AC4CEFD; Tue, 28 Oct 2025 11:52:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1761652330; bh=DwlhjHoMop499Dnm7S9clqxEbL1Rl0lz8m+TKGlPB8U=; h=From:To:Cc:Subject:Date:Reply-to:From; b=lKdf+1ZJFZFz018V11MP1szZJRWamT6tbyrgAezHC8hxAn3Gw12l6KgTDc3Q2Ik6b /m5BEYfhw3gyObHC7zy8kuaXxrOC6shOfu6AXsirqZCgY3OTFBNPKTJoQumcO9H0R4 k7JzYijPuGMJrGBx0HxEO+QlWBMIAgIVz1IyogA8= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2025-40038: KVM: SVM: Skip fastpath emulation on VM-Exit if next RIP isn't valid Date: Tue, 28 Oct 2025 12:48:15 +0100 Message-ID: <2025102811-CVE-2025-40038-6bd1@gregkh> X-Mailer: git-send-email 2.51.1 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=4393; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=nma+RZskOCsCJnA/rZZklBX2YElx1GzAR32+xVFLAQ0=; b=owGbwMvMwCRo6H6F97bub03G02pJDJkMa2tWCy7Pm5u3euazSWoFfhL2+ouEtjIWX0yr27pi/ 41gqasCHbEsDIJMDLJiiixftvEc3V9xSNHL0PY0zBxWJpAhDFycAjCRRR4MCy6HBHmIt91WXxHE u+JBU1BedUvQd4YFc7ceFP0aUsH29pjz3nrD4i1Je/MsAA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit From: Greg Kroah-Hartman Description =========== In the Linux kernel, the following vulnerability has been resolved: KVM: SVM: Skip fastpath emulation on VM-Exit if next RIP isn't valid Skip the WRMSR and HLT fastpaths in SVM's VM-Exit handler if the next RIP isn't valid, e.g. because KVM is running with nrips=false. SVM must decode and emulate to skip the instruction if the CPU doesn't provide the next RIP, and getting the instruction bytes to decode requires reading guest memory. Reading guest memory through the emulator can fault, i.e. can sleep, which is disallowed since the fastpath handlers run with IRQs disabled. BUG: sleeping function called from invalid context at ./include/linux/uaccess.h:106 in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 32611, name: qemu preempt_count: 1, expected: 0 INFO: lockdep is turned off. irq event stamp: 30580 hardirqs last enabled at (30579): [] vcpu_run+0x1787/0x1db0 [kvm] hardirqs last disabled at (30580): [] __schedule+0x1e2/0xed0 softirqs last enabled at (30570): [] fpu_swap_kvm_fpstate+0x44/0x210 softirqs last disabled at (30568): [] fpu_swap_kvm_fpstate+0x44/0x210 CPU: 298 UID: 0 PID: 32611 Comm: qemu Tainted: G U 6.16.0-smp--e6c618b51cfe-sleep #782 NONE Tainted: [U]=USER Hardware name: Google Astoria-Turin/astoria, BIOS 0.20241223.2-0 01/17/2025 Call Trace: dump_stack_lvl+0x7d/0xb0 __might_resched+0x271/0x290 __might_fault+0x28/0x80 kvm_vcpu_read_guest_page+0x8d/0xc0 [kvm] kvm_fetch_guest_virt+0x92/0xc0 [kvm] __do_insn_fetch_bytes+0xf3/0x1e0 [kvm] x86_decode_insn+0xd1/0x1010 [kvm] x86_emulate_instruction+0x105/0x810 [kvm] __svm_skip_emulated_instruction+0xc4/0x140 [kvm_amd] handle_fastpath_invd+0xc4/0x1a0 [kvm] vcpu_run+0x11a1/0x1db0 [kvm] kvm_arch_vcpu_ioctl_run+0x5cc/0x730 [kvm] kvm_vcpu_ioctl+0x578/0x6a0 [kvm] __se_sys_ioctl+0x6d/0xb0 do_syscall_64+0x8a/0x2c0 entry_SYSCALL_64_after_hwframe+0x4b/0x53 RIP: 0033:0x7f479d57a94b Note, this is essentially a reapply of commit 5c30e8101e8d ("KVM: SVM: Skip WRMSR fastpath on VM-Exit if next RIP isn't valid"), but with different justification (KVM now grabs SRCU when skipping the instruction for other reasons). The Linux kernel CVE team has assigned CVE-2025-40038 to this issue. Affected and fixed versions =========================== Issue introduced in 6.5 with commit b439eb8ab578557263815ba8581d02c1b730e348 and fixed in 6.6.113 with commit cd3efb93677c4b0cf76348882fb429165fee33fd Issue introduced in 6.5 with commit b439eb8ab578557263815ba8581d02c1b730e348 and fixed in 6.12.53 with commit f994e9c790ce97d3cf01af4d0a1b9add0c955aee Issue introduced in 6.5 with commit b439eb8ab578557263815ba8581d02c1b730e348 and fixed in 6.17.3 with commit da2a3c231f7f2a5ac146d972b8c1d7d84aff6d70 Issue introduced in 6.5 with commit b439eb8ab578557263815ba8581d02c1b730e348 and fixed in 6.18-rc1 with commit 0910dd7c9ad45a2605c45fd2bf3d1bcac087687c 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-2025-40038 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: arch/x86/kvm/svm/svm.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/cd3efb93677c4b0cf76348882fb429165fee33fd https://git.kernel.org/stable/c/f994e9c790ce97d3cf01af4d0a1b9add0c955aee https://git.kernel.org/stable/c/da2a3c231f7f2a5ac146d972b8c1d7d84aff6d70 https://git.kernel.org/stable/c/0910dd7c9ad45a2605c45fd2bf3d1bcac087687c