ghsa-x6qv-96vx-xf3h
Vulnerability from github
Published
2024-05-19 09:34
Modified
2024-05-19 09:34
Details

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.

Show details on source website


{
  "affected": [],
  "aliases": [
    "CVE-2024-35873"
  ],
  "database_specific": {
    "cwe_ids": [],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2024-05-19T09:15:08Z",
    "severity": null
  },
  "details": "In the Linux kernel, the following vulnerability has been resolved:\n\nriscv: Fix vector state restore in rt_sigreturn()\n\nThe RISC-V Vector specification states in \"Appendix D: Calling\nConvention for Vector State\" [1] that \"Executing a system call causes\nall caller-saved vector registers (v0-v31, vl, vtype) and vstart to\nbecome unspecified.\". In the RISC-V kernel this is called \"discarding\nthe vstate\".\n\nReturning from a signal handler via the rt_sigreturn() syscall, vector\ndiscard is also performed. However, this is not an issue since the\nvector state should be restored from the sigcontext, and therefore not\ncare about the vector discard.\n\nThe \"live state\" is the actual vector register in the running context,\nand the \"vstate\" is the vector state of the task. A dirty live state,\nmeans that the vstate and live state are not in synch.\n\nWhen vectorized user_from_copy() was introduced, an bug sneaked in at\nthe restoration code, related to the discard of the live state.\n\nAn example when this go wrong:\n\n  1. A userland application is executing vector code\n  2. The application receives a signal, and the signal handler is\n     entered.\n  3. The application returns from the signal handler, using the\n     rt_sigreturn() syscall.\n  4. The live vector state is discarded upon entering the\n     rt_sigreturn(), and the live state is marked as \"dirty\", indicating\n     that the live state need to be synchronized with the current\n     vstate.\n  5. rt_sigreturn() restores the vstate, except the Vector registers,\n     from the sigcontext\n  6. rt_sigreturn() restores the Vector registers, from the sigcontext,\n     and now the vectorized user_from_copy() is used. The dirty live\n     state from the discard is saved to the vstate, making the vstate\n     corrupt.\n  7. rt_sigreturn() returns to the application, which crashes due to\n     corrupted vstate.\n\nNote that the vectorized user_from_copy() is invoked depending on the\nvalue of CONFIG_RISCV_ISA_V_UCOPY_THRESHOLD. Default is 768, which\nmeans that vlen has to be larger than 128b for this bug to trigger.\n\nThe fix is simply to mark the live state as non-dirty/clean prior\nperforming the vstate restore.",
  "id": "GHSA-x6qv-96vx-xf3h",
  "modified": "2024-05-19T09:34:46Z",
  "published": "2024-05-19T09:34:46Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2024-35873"
    },
    {
      "type": "WEB",
      "url": "https://git.kernel.org/stable/c/5b16d904e910183181b9d90efa957c787a8ac91b"
    },
    {
      "type": "WEB",
      "url": "https://git.kernel.org/stable/c/c27fa53b858b4ee6552a719aa599c250cf98a586"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}


Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Sightings

Author Source Type Date

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or seen somewhere by the user.
  • Confirmed: The vulnerability is confirmed from an analyst perspective.
  • Exploited: This vulnerability was exploited and seen by the user reporting the sighting.
  • Patched: This vulnerability was successfully patched by the user reporting the sighting.
  • Not exploited: This vulnerability was not exploited or seen by the user reporting the sighting.
  • Not confirmed: The user expresses doubt about the veracity of the vulnerability.
  • Not patched: This vulnerability was not successfully patched by the user reporting the sighting.