# CVE-2024-35873: riscv: Fix vector state restore in rt\_sigreturn()

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** MEDIUM 5.5
- **CVSS:** 5.5 (v3.1, NVD) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: None; Integrity impact: None; Availability impact: High
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Not remotely exploitable (local or adjacent access needed)
- **EPSS:** 0.27% (percentile 12, 2026-11-28)
- **Published:** 2024-05-19T08:34:30.928Z
- **Modified:** 2026-06-17T07:35:36.513Z

## Who should check

- Anyone running Linux \>= c2a658d419246108c9bf065ec347355de5ba8a05, \< 5b16d904e910183181b9d90efa957c787a8ac91b; \>= c2a658d419246108c9bf065ec347355de5ba8a05, \< c27fa53b858b4ee6552a719aa599c250cf98a586
- Anyone running Linux 6.8

## 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 and fixed versions

- Linux: \>= c2a658d419246108c9bf065ec347355de5ba8a05, \< 5b16d904e910183181b9d90efa957c787a8ac91b; \>= c2a658d419246108c9bf065ec347355de5ba8a05, \< c27fa53b858b4ee6552a719aa599c250cf98a586 (cvelist)
- Linux: 6.8 (cvelist)

## Mitigation

- No fix listed yet: follow the vendor advisory.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2024-35873. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2024-35873.md
Affected: Linux >= c2a658d419246108c9bf065ec347355de5ba8a05, < 5b16d904e910183181b9d90efa957c787a8ac91b; >= c2a658d419246108c9bf065ec347355de5ba8a05, < c27fa53b858b4ee6552a719aa599c250cf98a586; Linux 6.8
Fixed in: Linux 5b16d904e910183181b9d90efa957c787a8ac91b

Steps:
1. Search this machine and project for Linux: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2024-35873 being exploited?

There is no confirmed exploitation: CVE-2024-35873 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.27% chance of exploitation in the next 30 days (as of 2026-11-28).

### How serious is CVE-2024-35873?

Medium: CVSS 5.5 (v3.1, scored by NVD). Not remotely exploitable (local or adjacent access needed).

### Which versions are affected by CVE-2024-35873?

Linux \>= c2a658d419246108c9bf065ec347355de5ba8a05, \< 5b16d904e910183181b9d90efa957c787a8ac91b; \>= c2a658d419246108c9bf065ec347355de5ba8a05, \< c27fa53b858b4ee6552a719aa599c250cf98a586; Linux 6.8.

### Is there a fix for CVE-2024-35873?

Yes. Fixed in Linux 5b16d904e910183181b9d90efa957c787a8ac91b. No fix listed yet: follow the vendor advisory.

### How do I check if I'm affected by CVE-2024-35873?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- patch: <https://git.kernel.org/stable/c/5b16d904e910183181b9d90efa957c787a8ac91b>
- patch: <https://git.kernel.org/stable/c/c27fa53b858b4ee6552a719aa599c250cf98a586>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2024-35873>

HTML: <https://flawdb.com/CVE-2024-35873> · JSON: <https://flawdb.com/api/v1/entries/CVE-2024-35873>
