GHSA-hv7x-f3pv-gpwr

Suggest an improvement
Source
https://github.com/advisories/GHSA-hv7x-f3pv-gpwr
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2021/08/GHSA-hv7x-f3pv-gpwr/GHSA-hv7x-f3pv-gpwr.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-hv7x-f3pv-gpwr
Aliases
Published
2021-08-25T20:44:46Z
Modified
2023-11-08T04:01:16.038525Z
Severity
  • 7.5 (High) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H CVSS Calculator
Summary
Wrong memory orderings violates mutual exclusion in spin
Details

Wrong memory orderings inside the RwLock implementation allow for two writers to acquire the lock at the same time. The drop implementation used Ordering::Relaxed, which allows the compiler or CPU to reorder a mutable access on the locked data after the lock has been yielded.

Only users of the RwLock implementation are affected. Users of Once (including users of lazystatic with the spinno_std feature enabled) are NOT affected.

On strongly ordered CPU architectures like x86, the only real way that this would lead to a memory corruption is if the compiler reorders an access after the lock is yielded, which is possible but in practice unlikely. It is a more serious issue on weakly ordered architectures such as ARM which, except in the presence of certain instructions, allow the hardware to decide which accesses are seen at what times. Therefore on an ARM system it is likely that using the wrong memory ordering would result in a memory corruption, even if the compiler itself doesn't reorder the memory accesses in a buggy way.

Database specific
{
    "nvd_published_at": null,
    "cwe_ids": [
        "CWE-662"
    ],
    "severity": "HIGH",
    "github_reviewed": true,
    "github_reviewed_at": "2021-08-19T21:22:40Z"
}
References

Affected packages

crates.io / spin

Package

Affected ranges

Type
SEMVER
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
0.5.2

Ecosystem specific

{
    "affected_functions": [
        "spin::RwLock::new"
    ]
}