Created
November 6, 2025 02:39
-
-
Save Rexicon226/4a627849c65bf293169a402e40219cc6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From e9b300e1579d456fd307659f86d8ac0373a25fea Mon Sep 17 00:00:00 2001 | |
| From: David Rubin <[email protected]> | |
| Date: Wed, 5 Nov 2025 18:26:33 -0800 | |
| Subject: [PATCH] explicit `PROT_WRITE` in `zero_bss` is redundant | |
| The `PAGE_WRITE` check already protects the `memset`. | |
| The Zig compiler uses `memsz` to reserve virtual address | |
| space that can be used by future updates, including | |
| in non-writable sections such as `.text`. | |
| However, it also aligns `filesz` to the target page size, | |
| so partial zeroing is never necassary for these incremental | |
| binaries. | |
| When the host page size is larger than the target page | |
| size, a single host page can represent multiple target pages. | |
| `page_get_flags` takes this into account and merges the permissions | |
| across the target pages. Therefore, if just one page in the | |
| list of pages represented by a host page is writable, the | |
| entire page must be writable. | |
| Every section is either entirely bss, thus already target page | |
| aligned, or if partially aligned then the non-bss part will | |
| have been writable (because it's a data section) and will cause | |
| at least of part of the current host page to be writable. | |
| --- | |
| linux-user/elfload.c | 6 ------ | |
| 1 file changed, 6 deletions(-) | |
| diff --git a/linux-user/elfload.c b/linux-user/elfload.c | |
| index 0002d5b..06eb5fd 100644 | |
| --- a/linux-user/elfload.c | |
| +++ b/linux-user/elfload.c | |
| @@ -449,12 +449,6 @@ static bool zero_bss(abi_ulong start_bss, abi_ulong end_bss, | |
| { | |
| abi_ulong align_bss; | |
| - /* We only expect writable bss; the code segment shouldn't need this. */ | |
| - if (!(prot & PROT_WRITE)) { | |
| - error_setg(errp, "PT_LOAD with non-writable bss"); | |
| - return false; | |
| - } | |
| - | |
| align_bss = TARGET_PAGE_ALIGN(start_bss); | |
| end_bss = TARGET_PAGE_ALIGN(end_bss); | |
| -- | |
| 2.47.2 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment