libdwfl: Remove p_align sanity check from elf_from_memory.
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>
diff --git a/libdwfl/elf-from-memory.c b/libdwfl/elf-from-memory.c
index df9fbe6..b35fac7 100644
--- a/libdwfl/elf-from-memory.c
+++ b/libdwfl/elf-from-memory.c
@@ -206,12 +206,10 @@
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 @@
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 @@
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;