Stream: git-wasmtime

Topic: wasmtime / PR #8918 Fix segfault with custom page sizes o...


view this post on Zulip Wasmtime GitHub notifications bot (Jul 08 2024 at 20:21):

alexcrichton opened PR #8918 from alexcrichton:fix-aarch64 to bytecodealliance:main:

This commit fixes an issue with static memory initialization and custom page sizes interacting together on aarch64 Linux. (is that specific enough?)

When static memory initialization is enabled chunks of memory to initialize the linear memory are made in host-page-size increments of memory. This is done to enable page-mapping via copy-on-write if customized. With the custom page sizes proposal, however, for the first time it's possible for a linear memory to be smaller than this chunk of memory. This means that a virtual memory allocation of a single host page can be made which is smaller than the initialization chunk.

This currently only happens on aarch64 Linux where we coarsely approximate that the host page size is 64k but many hosts run with 4k pages. This means that a 64k initializer is created but the host only allocates 4k for a linear memory. This means that memory initialization can crash when a 64k initializer is copied into a 4k memory.

This was not caught via fuzzing because fuzzing only runs on x86_64. This was not caught via CI because on CI guard pages are disabled entirely on QEMU and we got lucky in that a number of virtual memory allocations were all placed next to each other meaning that this copy was probably corrupting some other memory. Locally this was found by running tests on main as-is on AArch64 Linux (by bjorn3).

This commit implements a few safeguards and a fix for this issue:

<!--
Please make sure you include the following information:

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->

view this post on Zulip Wasmtime GitHub notifications bot (Jul 08 2024 at 20:21):

alexcrichton requested fitzgen for a review on PR #8918.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 08 2024 at 20:21):

alexcrichton requested wasmtime-core-reviewers for a review on PR #8918.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 08 2024 at 21:04):

fitzgen submitted PR review:

Nice! Thank you!

view this post on Zulip Wasmtime GitHub notifications bot (Jul 08 2024 at 21:21):

fitzgen merged PR #8918.


Last updated: Dec 23 2024 at 12:05 UTC