Lucene search

K
cve416baaa9-dc9f-4396-8d5f-8c081fb06d67CVE-2021-4440
HistoryJun 25, 2024 - 3:15 p.m.

CVE-2021-4440

2024-06-2515:15:11
416baaa9-dc9f-4396-8d5f-8c081fb06d67
web.nvd.nist.gov
19
linux kernel
vulnerability
x86/xen

6.4 Medium

AI Score

Confidence

High

0.0004 Low

EPSS

Percentile

9.1%

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 <[email protected]>
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:
   ...
   &lt;+342&gt;:   swapgs
   &lt;+345&gt;:   xchg   %ax,%ax
   &lt;+347&gt;:   verw   -0x1a2(%rip)  &lt;------
   &lt;+354&gt;:   sysretq

]

Affected configurations

Vulners
Node
linuxlinux_kernelRange5.10.2155.10.218

CNA Affected

[
  {
    "product": "Linux",
    "vendor": "Linux",
    "defaultStatus": "unaffected",
    "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
    "programFiles": [
      "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"
    ],
    "versions": [
      {
        "version": "cea750c99d8f",
        "lessThan": "1424ab4bb386",
        "status": "affected",
        "versionType": "git"
      }
    ]
  },
  {
    "product": "Linux",
    "vendor": "Linux",
    "defaultStatus": "unaffected",
    "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
    "programFiles": [
      "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"
    ],
    "versions": [
      {
        "version": "5.10.215",
        "lessThan": "5.10.218",
        "status": "affected",
        "versionType": "custom"
      }
    ]
  }
]

6.4 Medium

AI Score

Confidence

High

0.0004 Low

EPSS

Percentile

9.1%