Skip to content

Patch for CVE-2021-32629 to stable-v0.26 for security point release.#2919

Merged
cfallin merged 2 commits into
bytecodealliance:stable-v0.26from
cfallin:v0.26-patches
May 21, 2021
Merged

Patch for CVE-2021-32629 to stable-v0.26 for security point release.#2919
cfallin merged 2 commits into
bytecodealliance:stable-v0.26from
cfallin:v0.26-patches

Conversation

@cfallin
Copy link
Copy Markdown
Member

@cfallin cfallin commented May 21, 2021

This PR is a cherrypick of the fix for the CVE (and related #2840) on top of the v0.26.0 release, using a new stable-v0.26 branch. Once this merges, I will version-bump and release v0.26.1 (and Cranelift v0.73.1) off of this branch.

bnjbvr and others added 2 commits May 20, 2021 18:44
Fixes bytecodealliance#2839. See also the issue description and comments in this commits for
details of what the fix is about here.
Previously, the x64 backend's ABI code would generate a sign-extending
load when loading a less-than-64-bit integer from a spillslot. This is
incorrect: e.g., for i32s > 0x80000000, this would result in all high
bits set.

This interacts poorly with another optimization. Normally, the invariant
is that the high bits of a register holding a value of a certain type,
beyond that type's bits, are undefined. However, as an optimization, we
recognize and use the fact that on x86-64, 32-bit instructions zero the
upper 32 bits. This allows us to elide a 32-to-64-bit zero-extend op
(turning it into just a move, which can then sometimes disappear
entirely due to register coalescing).

If a spill and reload happen between the production of a 32-bit value
from an instruction known to zero the upper bits and its use, then we
will rely on zero upper bits that might actually be set by a
sign-extend. This will result in incorrect execution.

As a fix, we stick to a simple invariant: we always spill and reload a
full 64 bits when handling integer registers on x64. This ensures that
no bits are mangled.
@cfallin cfallin requested a review from iximeow May 21, 2021 19:12
Copy link
Copy Markdown
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want, wanna fold the version bumps into this as well to double-check?

Copy link
Copy Markdown
Contributor

@iximeow iximeow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for shepherding these fixes along!

@cfallin cfallin merged commit e481824 into bytecodealliance:stable-v0.26 May 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants