Skip to content

Cranelift/aarch64: fix br_tables with very large target count. - #14826

Merged
alexcrichton merged 3 commits into
bytecodealliance:mainfrom
pchickey:fix_ghsa_mghf_main
Oct 19, 2026
Merged

alexcrichton merged 3 commits into
bytecodealliance:mainfrom
pchickey:fix_ghsa_mghf_main

Conversation

@pchickey

Copy link
Copy Markdown
Contributor

Previously, the JTSequence macro-instruction contained a conditional branch for the default (selector greater than table size) case. This default branch on aarch64 has a +/- 1MiB range. The JTSequence also contains the entire table of 32-bit offsets for each br_table target. As a result of these two facts, a branch may have an out-of-bounds target and silently wrap the offset, resulting in an incorrect branch target.

This PR fixes the sequence to instead use the offset table for the default case too. The conditional branch is converted into a conditional-select that clamps the index to the last table entry (which we fill with the default target) if out-of-bounds.

This PR was authored by @cfallin

Previously, the `JTSequence` macro-instruction contained a conditional
branch for the default (selector greater than table size) case. This
default branch on aarch64 has a +/- 1MiB range. The `JTSequence` also
contains the entire table of 32-bit offsets for each `br_table`
target. As a result of these two facts, a branch may have an
out-of-bounds target and silently wrap the offset, resulting in an
incorrect branch target.

This PR fixes the sequence to instead use the offset table for the
default case too. The conditional branch is converted into a
conditional-select that clamps the index to the last table
entry (which we fill with the default target) if out-of-bounds.
@alexcrichton
alexcrichton added this pull request to the merge queue Oct 19, 2026
Merged via the queue into bytecodealliance:main with commit e61df1b Oct 19, 2026
53 checks passed
This was referenced Oct 20, 2026
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.

3 participants