Skip to content

Commit 4b7b20a

Browse files
Fabiano Rosasrth7680
authored andcommitted
elfload: Fix alignment when unmapping excess reservation
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: c81d1fa ("linux-user: Honor elf alignment when placing images") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1913 Signed-off-by: Fabiano Rosas <[email protected]> [rth: Align load_end as well.] Signed-off-by: Richard Henderson <[email protected]> Message-ID: <[email protected]>
1 parent 1bbcae5 commit 4b7b20a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

linux-user/elfload.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3351,8 +3351,8 @@ static void load_elf_image(const char *image_name, const ImageSource *src,
33513351

33523352
if (align_size != reserve_size) {
33533353
abi_ulong align_addr = ROUND_UP(load_addr, align);
3354-
abi_ulong align_end = align_addr + reserve_size;
3355-
abi_ulong load_end = load_addr + align_size;
3354+
abi_ulong align_end = TARGET_PAGE_ALIGN(align_addr + reserve_size);
3355+
abi_ulong load_end = TARGET_PAGE_ALIGN(load_addr + align_size);
33563356

33573357
if (align_addr != load_addr) {
33583358
target_munmap(load_addr, align_addr - load_addr);

0 commit comments

Comments
 (0)