qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] elfload: Fix alignment when unmapping excess reservation
@ 2025-02-13 14:35 Fabiano Rosas
  2025-02-15 19:06 ` Richard Henderson
  2025-02-19  7:42 ` Michael Tokarev
  0 siblings, 2 replies; 5+ messages in thread
From: Fabiano Rosas @ 2025-02-13 14:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: Richard Henderson, Alex Bennée, Dario Faggioli

When complying with the alignment requested in the ELF and unmapping
the excess reservation, having align_end not aligned to the guest page
causes the unmap to be rejected by the alignment check at
target_munmap and later brk adjustments hit an EEXIST.

Fix by aligning the start of region to be unmapped.

Fixes: c81d1fafa6 ("linux-user: Honor elf alignment when placing images")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1913
Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
In the bug there was mention of the vdso landing in the wrong spot,
but I don't see evidence of this in my testing. Looking at the
addresses in the bug report, there seems to have been a mistake
because I don't see an overlap there either.
---
 linux-user/elfload.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index a2c152e5ad..05ee5e74fd 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -3351,7 +3351,7 @@ static void load_elf_image(const char *image_name, const ImageSource *src,
 
     if (align_size != reserve_size) {
         abi_ulong align_addr = ROUND_UP(load_addr, align);
-        abi_ulong align_end = align_addr + reserve_size;
+        abi_ulong align_end = TARGET_PAGE_ALIGN(align_addr + reserve_size);
         abi_ulong load_end = load_addr + align_size;
 
         if (align_addr != load_addr) {
-- 
2.35.3



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-02-19 13:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-13 14:35 [RFC PATCH] elfload: Fix alignment when unmapping excess reservation Fabiano Rosas
2025-02-15 19:06 ` Richard Henderson
2025-02-15 19:08   ` Richard Henderson
2025-02-19  7:42 ` Michael Tokarev
2025-02-19 13:05   ` Fabiano Rosas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).