CVE-2021-4440
x86/xen: Drop USERGS_SYSRET64 paravirt call
Severity Score
Exploit Likelihood
Affected Versions
Public Exploits
0Exploited in Wild
-Decision
Descriptions
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 <carnil@debian.org>
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
]
En el kernel de Linux, se resolvió la siguiente vulnerabilidad: x86/xen: elimine el commit de llamada paravirt USERGS_SYSRET64 afd30525a659ac0ae0904f0cb4a2ca75522c3123 en sentido ascendente. USERGS_SYSRET64 se usa para regresar de una llamada al sistema a través de SYSRET, pero un invitado Xen PV usará la hiperllamada IRET, ya que no hay ninguna hiperllamada PV sysret definida. Entonces, en lugar de probar todos los requisitos previos para hacer un sysret y luego alterar la pila para Xen PV nuevamente para hacer un iret, simplemente use la salida iret desde el principio. Esto se puede hacer fácilmente a través de una ALTERNATIVA como ya se hace para el caso de compatibilidad con sysenter. Cabe señalar que esto reduce la optimización en Xen para no restaurar algunos registros al regresar al modo de usuario, pero parece que las instrucciones guardadas en el kernel compensan con creces esta caída (una compilación del kernel en un invitado Xen PV fue un poco más rápido con este parche aplicado). Mientras lo hace, elimine los restos obsoletos de sysret32. [pawan: Brad Spengler y Salvatore Bonaccorso informaron de un problema con el commit del backport 5.10 edc702b4a820 ("x86/entry_64: Agregar VERW justo antes de la transición del espacio de usuario"). Cuando CONFIG_PARAVIRT_XXL=y, CLEAR_CPU_BUFFERS no se ejecuta en la ruta syscall_return_via_sysret ya que USERGS_SYSRET64 está parcheado en tiempo de ejecución para: .cpu_usergs_sysret64 = { 0x0f, 0x01, 0xf8, 0x48, 0x0f, 0x07 }, // swapgs; sysretq al que le falta CLEAR_CPU_BUFFERS. Resulta que eliminar USERGS_SYSRET64 simplifica el código, permitiendo que CLEAR_CPU_BUFFERS se agregue explícitamente a la ruta syscall_return_via_sysret. A continuación se muestra CONFIG_PARAVIRT_XXL=y y se aplicó este parche: syscall_return_via_sysret: ... <+342>: swapgs <+345>: xchg %ax,%ax <+347>: verw -0x1a2(%rip) <---- -- <+354>: sysretq ]
CVSS Scores
SSVC
- Decision:Track*
Timeline
- 2024-06-25 CVE Reserved
- 2024-06-25 CVE Published
- 2024-06-26 EPSS Updated
- 2024-12-19 CVE Updated
- ---------- Exploited in Wild
- ---------- KEV Due Date
- ---------- First Exploit
CWE
- CWE-400: Uncontrolled Resource Consumption
CAPEC
References (3)
URL | Tag | Source |
---|---|---|
https://git.kernel.org/stable/c/cea750c99d8f6391080c420f811a46b21bad7cf4 | Vuln. Introduced | |
https://grsecurity.net/cve-2021-4440_linux_cna_case_study |
URL | Date | SRC |
---|
URL | Date | SRC |
---|---|---|
https://git.kernel.org/stable/c/1424ab4bb386df9cc590c73afa55f13e9b00dea2 | 2024-05-25 |
URL | Date | SRC |
---|
Affected Vendors, Products, and Versions
Vendor | Product | Version | Other | Status | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Vendor | Product | Version | Other | Status | <-- --> | Vendor | Product | Version | Other | Status |
Linux Search vendor "Linux" | Linux Kernel Search vendor "Linux" for product "Linux Kernel" | >= 5.10.215 < 5.10.218 Search vendor "Linux" for product "Linux Kernel" and version " >= 5.10.215 < 5.10.218" | en |
Affected
|