Vulnerability · Published May 19, 2024 · Assigned by Linux

CVE-2024-35873riscv: Fix vector state restore in rt_sigreturn()

Medium 5.5

In plain English

A medium-severity security flaw in Linux from Linux. There are no confirmed reports of exploitation so far. The chance it is exploited in the next 30 days is estimated at 0.2% (higher than 10% of all known vulnerabilities). Fixed versions are available - upgrade the affected package.

Severity (CVSS NVD)5.5Medium
Exploit odds (30 days)0.2%top 90.4% of all CVEs
Exploited in the wildNo reportsCISA SSVC: none
Attack toolingNoneno public tooling known

Official description

In the Linux kernel, the following vulnerability has been resolved: riscv: Fix vector state restore in rt_sigreturn() The RISC-V Vector specification states in "Appendix D: Calling Convention for Vector State" [1] that "Executing a system call causes all caller-saved vector registers (v0-v31, vl, vtype) and vstart to become unspecified.". In the RISC-V kernel this is called "discarding the vstate". Returning from a signal handler via the rt_sigreturn() syscall, vector discard is also performed. However, this is not an issue since the vector state should be restored from the sigcontext, and therefore not care about the vector discard. The "live state" is the actual vector register in the running context, and the "vstate" is the vector state of the task. A dirty live state, means that the vstate and live state are not in synch. When vectorized user_from_copy() was introduced, an bug sneaked in at the restoration code, related to the discard of the live state. An example when this go wrong: 1. A userland application is executing vector code 2. The application receives a signal, and the signal handler is entered. 3. The application returns from the signal handler, using the rt_sigreturn() syscall. 4. The live vector state is discarded upon entering the rt_sigreturn(), and the live state is marked as "dirty", indicating that the live state need to be synchronized with the current vstate. 5. rt_sigreturn() restores the vstate, except the Vector registers, from the sigcontext 6. rt_sigreturn() restores the Vector registers, from the sigcontext, and now the vectorized user_from_copy() is used. The dirty live state from the discard is saved to the vstate, making the vstate corrupt. 7. rt_sigreturn() returns to the application, which crashes due to corrupted vstate. Note that the vectorized user_from_copy() is invoked depending on the value of CONFIG_RISCV_ISA_V_UCOPY_THRESHOLD. Default is 768, which means that vlen has to be larger than 128b for this bug to trigger. The fix is simply to mark the live state as non-dirty/clean prior performing the vstate restore.

Affected packages & fixed versions

EcosystemPackageFixed inAdvisory
Debian:13linux6.8.9-1DEBIAN-CVE-2024-35873
Debian:14linux6.8.9-1DEBIAN-CVE-2024-35873
Ubuntu:24.04:LTSlinux6.8.0-38.38UBUNTU-CVE-2024-35873
Ubuntu:22.04:LTSlinux-allwinner-5.19no fix listedUBUNTU-CVE-2024-35873
Ubuntu:24.04:LTSlinux-aws6.8.0-1011.12UBUNTU-CVE-2024-35873
Ubuntu:22.04:LTSlinux-aws-5.19no fix listedUBUNTU-CVE-2024-35873
Ubuntu:22.04:LTSlinux-aws-6.2no fix listedUBUNTU-CVE-2024-35873
Ubuntu:22.04:LTSlinux-aws-6.86.8.0-1011.12~22.04.1UBUNTU-CVE-2024-35873
Ubuntu:24.04:LTSlinux-azure6.8.0-1010.10UBUNTU-CVE-2024-35873
Ubuntu:22.04:LTSlinux-azure-5.19no fix listedUBUNTU-CVE-2024-35873
Ubuntu:22.04:LTSlinux-azure-6.2no fix listedUBUNTU-CVE-2024-35873
Ubuntu:22.04:LTSlinux-azure-6.86.8.0-1010.10~22.04.1UBUNTU-CVE-2024-35873
Ubuntu:22.04:LTSlinux-azure-fde-5.19no fix listedUBUNTU-CVE-2024-35873
Ubuntu:22.04:LTSlinux-azure-fde-6.2no fix listedUBUNTU-CVE-2024-35873
Ubuntu:24.04:LTSlinux-gcp6.8.0-1010.11UBUNTU-CVE-2024-35873
Ubuntu:22.04:LTSlinux-gcp-5.19no fix listedUBUNTU-CVE-2024-35873
Ubuntu:22.04:LTSlinux-gcp-6.2no fix listedUBUNTU-CVE-2024-35873
Ubuntu:24.04:LTSlinux-gke6.8.0-1006.9UBUNTU-CVE-2024-35873
Ubuntu:22.04:LTSlinux-hwe-5.19no fix listedUBUNTU-CVE-2024-35873
Ubuntu:22.04:LTSlinux-hwe-6.2no fix listedUBUNTU-CVE-2024-35873
Ubuntu:24.04:LTSlinux-ibm6.8.0-1008.8UBUNTU-CVE-2024-35873
Ubuntu:24.04:LTSlinux-intel6.8.0-1007.14UBUNTU-CVE-2024-35873
Ubuntu:22.04:LTSlinux-intel-iot-realtimeno fix listedUBUNTU-CVE-2024-35873
Ubuntu:24.04:LTSlinux-lowlatency6.8.0-38.38.1UBUNTU-CVE-2024-35873
Ubuntu:22.04:LTSlinux-lowlatency-hwe-5.19no fix listedUBUNTU-CVE-2024-35873
Ubuntu:22.04:LTSlinux-lowlatency-hwe-6.2no fix listedUBUNTU-CVE-2024-35873
Ubuntu:24.04:LTSlinux-nvidia6.8.0-1009.9UBUNTU-CVE-2024-35873
Ubuntu:22.04:LTSlinux-nvidia-6.2no fix listedUBUNTU-CVE-2024-35873
Ubuntu:22.04:LTSlinux-nvidia-6.86.8.0-1009.9~22.04.1UBUNTU-CVE-2024-35873
Ubuntu:22.04:LTSlinux-oem-5.17no fix listedUBUNTU-CVE-2024-35873
Ubuntu:22.04:LTSlinux-oem-6.0no fix listedUBUNTU-CVE-2024-35873
Ubuntu:22.04:LTSlinux-oem-6.1no fix listedUBUNTU-CVE-2024-35873
Ubuntu:24.04:LTSlinux-oem-6.86.8.0-1008.8UBUNTU-CVE-2024-35873
Ubuntu:24.04:LTSlinux-oracle6.8.0-1008.8UBUNTU-CVE-2024-35873
Ubuntu:22.04:LTSlinux-oracle-6.86.8.0-1008.8~22.04.1UBUNTU-CVE-2024-35873
Ubuntu:24.04:LTSlinux-raspi6.8.0-1007.7UBUNTU-CVE-2024-35873
Ubuntu:22.04:LTSlinux-realtimeno fix listedUBUNTU-CVE-2024-35873
Ubuntu:22.04:LTSlinux-riscvno fix listedUBUNTU-CVE-2024-35873
Ubuntu:24.04:LTSlinux-riscv6.8.0-38.38.1UBUNTU-CVE-2024-35873
Ubuntu:22.04:LTSlinux-riscv-5.19no fix listedUBUNTU-CVE-2024-35873
Ubuntu:22.04:LTSlinux-starfive-5.19no fix listedUBUNTU-CVE-2024-35873
Ubuntu:22.04:LTSlinux-starfive-6.2no fix listedUBUNTU-CVE-2024-35873

Affected products (as reported)

VendorProductVersions
Linux Linux c2a658d419246108c9bf065ec347355de5ba8a05 – before 5b16d904e910183181b9d90efa957c787a8ac91bc2a658d419246108c9bf065ec347355de5ba8a05 – before c27fa53b858b4ee6552a719aa599c250cf98a586
Linux Linux 6.8

References