]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdwfl: Remove p_align sanity check from elf_from_memory.
authorMark Wielaard <mjw@redhat.com>
Fri, 19 Dec 2014 14:40:16 +0000 (15:40 +0100)
committerMark Wielaard <mjw@redhat.com>
Fri, 19 Dec 2014 17:07:38 +0000 (18:07 +0100)
In commit f15bcd "elf_from_remote_memory should use pagesize, not p_align"
we already relaxed the p_align sanity check to allow alignment of the
segment against the pagesize since that is what the glibc dynamic linker
actually does. But on some architectures the kernel inserts a vdso with
a completely bogus p_align for some PT_LOAD segments. So just drop the
whole sanity check and allow anything since we won't use p_align, but
always already use pagesize anyway.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
libdwfl/ChangeLog
libdwfl/elf-from-memory.c

index f6db301c321bb97a67e6f016f921594a37888354..3d3edc5f884b0180baf647b86389974a57bee50a 100644 (file)
@@ -1,3 +1,7 @@
+2014-12-19  Mark Wielaard  <mjw@redhat.com>
+
+       * elf-from-memory.c (handle_segment): Remove palign sanity check.
+
 2014-12-18  Mark Wielaard  <mjw@redhat.com>
 
        * relocate.c (resolve_symbol): Make sure symstrdata->d_buf != NULL.
index df9fbe695659b260bc9f357a6c80f855abd069ad..b35fac71916d11f555aefd211cc36c5b6e409d7e 100644 (file)
@@ -206,12 +206,10 @@ elf_from_remote_memory (GElf_Addr ehdr_vma,
         found_base yet).  Returns true if sanity checking failed,
         false otherwise.  */
       inline bool handle_segment (GElf_Addr vaddr, GElf_Off offset,
-                                 GElf_Xword filesz, GElf_Xword memsz,
-                                 GElf_Xword palign)
+                                 GElf_Xword filesz, GElf_Xword memsz)
        {
-         /* Sanity check the alignment requirements.  */
-         if ((palign & (pagesize - 1)) != 0
-             || ((vaddr - offset) & (palign - 1)) != 0)
+         /* Sanity check the segment load aligns with the pagesize.  */
+         if (((vaddr - offset) & (pagesize - 1)) != 0)
            return true;
 
          GElf_Off segment_end = ((offset + filesz + pagesize - 1)
@@ -238,8 +236,7 @@ elf_from_remote_memory (GElf_Addr ehdr_vma,
       for (uint_fast16_t i = 0; i < phnum; ++i)
        if (phdrs.p32[i].p_type == PT_LOAD)
          if (handle_segment (phdrs.p32[i].p_vaddr, phdrs.p32[i].p_offset,
-                             phdrs.p32[i].p_filesz, phdrs.p32[i].p_memsz,
-                             phdrs.p32[i].p_align))
+                             phdrs.p32[i].p_filesz, phdrs.p32[i].p_memsz))
            goto bad_elf;
       break;
 
@@ -250,8 +247,7 @@ elf_from_remote_memory (GElf_Addr ehdr_vma,
       for (uint_fast16_t i = 0; i < phnum; ++i)
        if (phdrs.p64[i].p_type == PT_LOAD)
          if (handle_segment (phdrs.p64[i].p_vaddr, phdrs.p64[i].p_offset,
-                             phdrs.p64[i].p_filesz, phdrs.p64[i].p_memsz,
-                             phdrs.p64[i].p_align))
+                             phdrs.p64[i].p_filesz, phdrs.p64[i].p_memsz))
            goto bad_elf;
       break;