Skip to content

Use unsigned shift in GetAlignment to avoid signed overflow - #2755

Merged
sbc100 merged 1 commit into
WebAssembly:mainfrom
aizu-m:getalignment-unsigned-shift
Jun 5, 2026
Merged

sbc100 merged 1 commit into
WebAssembly:mainfrom
aizu-m:getalignment-unsigned-shift

Conversation

@aizu-m

@aizu-m aizu-m commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Reading the two binary readers side by side, the load/store alignment immediate gets widened differently:

binary-reader-ir.cc:      1ull << alignment_log2
binary-reader-interp.cc:  1 << alignment_log2

The interp form shifts a signed int. CheckAlignment only rejects alignment_log2 >= 32, so a load or store in an untrusted module can carry alignment_log2 == 31, and 1 << 31 on int is signed overflow. Switching the literal to 1u makes the shift unsigned; the returned value is unchanged.

@sbc100
sbc100 merged commit 2d84a99 into WebAssembly:main Jun 5, 2026
17 checks passed
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.

2 participants