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 C4A4DBE71 for ; Tue, 25 Jun 2024 14:20:12 +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=1719325212; cv=none; b=YTDiAjZweRUZ4UeGK8m4Kqv/nls5H4xI7GvpU84DOGjTa5o0xoleSn/oTrYoa+D99fOXX2JChSdLjZwNIdmbXAXNqyDy37fDuKmzuNxhPPqZsjWCNBrXEgQcDQ6VU7rKw1Oe+Ug89OMPjrT25Bvq9ajKzqrzEwme9ci+shRn/k8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719325212; c=relaxed/simple; bh=LxrT5m+uvJ60JuBq6jZZ8vt7RVmzL09bmWr4b1QF2Ww=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=eEbRwGqGxwuVZ1ZFTTxxUzf0Y9JmYEsKWLU07HD4MiZjyxznl6rlzNBCnT2LptwO20ByuFm8jcWdh7m4C8gsC2XWhM7R0N5sWogIpzZwZDrhJxaC3Cc+TJSL7oBtBs6XkLVu+x2pUgUp+tgYFtUByc85FHyV7gAlp3PPc8qathg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=KNTxQRop; 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="KNTxQRop" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 070BCC32786; Tue, 25 Jun 2024 14:20:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1719325212; bh=LxrT5m+uvJ60JuBq6jZZ8vt7RVmzL09bmWr4b1QF2Ww=; h=From:To:Cc:Subject:Date:Reply-to:From; b=KNTxQRop183Z5ZaAp4zoKpyrhoCTXqdPOIk0DPLzGDlIA07gdvzTBt7vil9aVDx+g N+e8Jd20zERDltBwdobNAbvBl6B8A050wqBg63CF1SIoZ4ijZ4avdYeIWjj1W2JpJ1 C5g1mVwBAQenAjz+5BOiPdVaqIEClr5Fks8Yr3m4= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2021-4440: x86/xen: Drop USERGS_SYSRET64 paravirt call Date: Tue, 25 Jun 2024 16:20:07 +0200 Message-ID: <2024062506-CVE-2021-4440-f8f1@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=3503; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=LxrT5m+uvJ60JuBq6jZZ8vt7RVmzL09bmWr4b1QF2Ww=; b=owGbwMvMwCRo6H6F97bub03G02pJDGlVl8RqpTXiJ/bcM5x6Mt68WP1FSYt/qcA2U+m3N/h/p zB++t3cEcvCIMjEICumyPJlG8/R/RWHFL0MbU/DzGFlAhnCwMUpABO5PYFhfv5dE/9jcRMfTWXW Es4X5Pl+I8NfgGFB7+HrWdInjxa0LTfP0Gdcs6NjqlAoAA== 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: x86/xen: Drop USERGS_SYSRET64 paravirt call commit afd30525a659ac0ae0904f0cb4a2ca75522c3123 upstream. USERGS_SYSRET64 is used to return from a syscall via SYSRET, but a Xen PV guest will nevertheless use the IRET hypercall, as there is no sysret PV hypercall defined. So instead of testing all the prerequisites for doing a sysret and then mangling the stack for Xen PV again for doing an iret just use the iret exit from the beginning. This can easily be done via an ALTERNATIVE like it is done for the sysenter compat case already. It should be noted that this drops the optimization in Xen for not restoring a few registers when returning to user mode, but it seems as if the saved instructions in the kernel more than compensate for this drop (a kernel build in a Xen PV guest was slightly faster with this patch applied). While at it remove the stale sysret32 remnants. [ pawan: Brad Spengler and Salvatore Bonaccorso reported a problem with the 5.10 backport commit edc702b4a820 ("x86/entry_64: Add VERW just before userspace transition"). When CONFIG_PARAVIRT_XXL=y, CLEAR_CPU_BUFFERS is not executed in syscall_return_via_sysret path as USERGS_SYSRET64 is runtime patched to: .cpu_usergs_sysret64 = { 0x0f, 0x01, 0xf8, 0x48, 0x0f, 0x07 }, // swapgs; sysretq which is missing CLEAR_CPU_BUFFERS. It turns out dropping USERGS_SYSRET64 simplifies the code, allowing CLEAR_CPU_BUFFERS to be explicitly added to syscall_return_via_sysret path. Below is with CONFIG_PARAVIRT_XXL=y and this patch applied: syscall_return_via_sysret: ... <+342>: swapgs <+345>: xchg %ax,%ax <+347>: verw -0x1a2(%rip) <------ <+354>: sysretq ] The Linux kernel CVE team has assigned CVE-2021-4440 to this issue. Affected and fixed versions =========================== Issue introduced in 5.10.215 with commit cea750c99d8f and fixed in 5.10.218 with commit 1424ab4bb386 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-2021-4440 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/entry/entry_64.S arch/x86/include/asm/irqflags.h arch/x86/include/asm/paravirt.h arch/x86/include/asm/paravirt_types.h arch/x86/kernel/asm-offsets_64.c arch/x86/kernel/paravirt.c arch/x86/kernel/paravirt_patch.c arch/x86/xen/enlighten_pv.c arch/x86/xen/xen-asm.S arch/x86/xen/xen-ops.h 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/1424ab4bb386df9cc590c73afa55f13e9b00dea2