From: Mark Wielaard Date: Fri, 19 Dec 2014 14:40:16 +0000 (+0100) Subject: libdwfl: Remove p_align sanity check from elf_from_memory. X-Git-Tag: elfutils-0.161~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=32b6c6aa608d64529e863684d3d7ec3f49afe7fa;p=thirdparty%2Felfutils.git 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 --- diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index f6db301c3..3d3edc5f8 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,7 @@ +2014-12-19 Mark Wielaard + + * elf-from-memory.c (handle_segment): Remove palign sanity check. + 2014-12-18 Mark Wielaard * relocate.c (resolve_symbol): Make sure symstrdata->d_buf != NULL. diff --git a/libdwfl/elf-from-memory.c b/libdwfl/elf-from-memory.c index df9fbe695..b35fac719 100644 --- a/libdwfl/elf-from-memory.c +++ b/libdwfl/elf-from-memory.c @@ -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;