Skip to content

validate poll_oneoff in/out arrays against nsubscriptions#4964

Open
netliomax25-code wants to merge 1 commit into
bytecodealliance:mainfrom
netliomax25-code:poll-oneoff-array-bounds
Open

validate poll_oneoff in/out arrays against nsubscriptions#4964
netliomax25-code wants to merge 1 commit into
bytecodealliance:mainfrom
netliomax25-code:poll-oneoff-array-bounds

Conversation

@netliomax25-code

Copy link
Copy Markdown
  1. wasi_poll_oneoff validates a single wasi_subscription_t at in and a single wasi_event_t at out, then hands the wasm-controlled nsubscriptions to the poll backend, which reads in[0..nsubscriptions) and writes out[0..nevents).
  2. when a module points in/out near the end of its linear memory and passes nsubscriptions > 1, the trailing elements fall outside the validated range; on builds where hardware bounds checks are off and validate_native_addr is the active guard, that becomes an out-of-bounds read and write of memory next to the sandbox.
  3. validate the whole in and out arrays (sizeof * nsubscriptions), the way fd_read/fd_write/sock_recv already validate their iovec arrays. the libc-uvwasi wrapper carried the identical one-element check and gets the same fix.

Checked with hardware bounds checks disabled so validate_native_addr is the active guard: before the change, a module calling poll_oneoff with in/out one element from the page end and nsubscriptions=2 segfaults; after, the call returns an error and a normal single-subscription poll still returns 0.

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.

1 participant