Commit a8af6a86 authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[wasm] Discard system pages when removing access

If PKU is used, we just called {pkey_mprotect} and called it a day,
whereas {PageAllocator::SetPermissions} also discards the system pages
when switching to {kNoAccess} (both in {OS::SetPermissions}, which is
used by the default platform, as well as the GIN platform used in
Chrome).

In order to avoid memory regressions when using PKU, this CL changes the
PKU implementation to behave like the POSIX {OS::SetPermissions}
function and also discard system pages when removing all access.

R=jkummerow@chromium.org

Bug: v8:11974
Change-Id: I35f9c436925c1500e5884db1caf620c975586f7e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3424496Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78874}
parent e7f7c4bb
......@@ -174,6 +174,12 @@ bool SetPermissionsAndMemoryProtectionKey(
int ret = pkey_mprotect(address, size, protection, key);
if (ret == 0 && page_permissions == PageAllocator::kNoAccess) {
// Similar to {OS::SetPermissions}, also discard the pages after switching
// to no access. This is advisory; ignore errors and continue execution.
USE(page_allocator->DiscardSystemPages(address, size));
}
return ret == /* success */ 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment