]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
elf: Remove excessive p_align check on PT_LOAD segments [BZ #28688]
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 21 Dec 2021 20:35:47 +0000 (12:35 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 22 Dec 2021 13:12:30 +0000 (05:12 -0800)
p_align does not have to be a multiple of the page size.  Only PT_LOAD
segment layout should be aligned to the page size.

1: Remove p_align check against the page size.
2. Use the page size, instead of p_align, to check PT_LOAD segment layout.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
elf/dl-load.c

index 721593135e307f885c1cd61154572b46ddaa6b47..2a1443387f683f7eb787aa0f5836e15a6f50905a 100644 (file)
@@ -1133,16 +1133,11 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd,
        case PT_LOAD:
          /* A load command tells us to map in part of the file.
             We record the load commands and process them all later.  */
-         if (__glibc_unlikely ((ph->p_align & (GLRO(dl_pagesize) - 1)) != 0))
-           {
-             errstring = N_("ELF load command alignment not page-aligned");
-             goto lose;
-           }
          if (__glibc_unlikely (((ph->p_vaddr - ph->p_offset)
-                                & (ph->p_align - 1)) != 0))
+                                & (GLRO(dl_pagesize) - 1)) != 0))
            {
              errstring
-               = N_("ELF load command address/offset not properly aligned");
+               = N_("ELF load command address/offset not page-aligned");
              goto lose;
            }