]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
elf: Align argument of __munmap to page size [BZ #28676]
authorH.J. Lu <hjl.tools@gmail.com>
Mon, 13 Dec 2021 15:17:29 +0000 (07:17 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 14 Dec 2021 15:16:51 +0000 (07:16 -0800)
On Linux/x86-64, for elf/tst-align3, we now get

munmap(0x7f88f9401000, 1126424)         = 0

instead of

munmap(0x7f1615200018, 544768)          = -1 EINVAL (Invalid argument)

Reviewed-by: Florian Weimer <fweimer@redhat.com>
elf/dl-map-segments.h

index 70a4c4069502402886dc739105c193b0a85dedf1..54e606aa87334119fa70c69b595dc59950193d05 100644 (file)
@@ -55,6 +55,7 @@ _dl_map_segment (const struct loadcmd *c, ElfW(Addr) mappref,
       if (delta)
        __munmap ((void *) map_start, delta);
       ElfW(Addr) map_end = map_start_aligned + maplength;
+      map_end = ALIGN_UP (map_end, GLRO(dl_pagesize));
       delta = map_start + maplen - map_end;
       if (delta)
        __munmap ((void *) map_end, delta);