diff options
| author | Mark Wielaard <[email protected]> | 2014-12-19 15:40:16 +0100 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2014-12-19 18:07:38 +0100 |
| commit | 32b6c6aa608d64529e863684d3d7ec3f49afe7fa (patch) | |
| tree | 8a7a3cae8b2ed54e0844dc52dc3be556bdd574e2 | |
| parent | 898ed261444cdd817c2d9b3656209a291eb5e807 (diff) | |
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 <[email protected]>
| -rw-r--r-- | libdwfl/ChangeLog | 4 | ||||
| -rw-r--r-- | libdwfl/elf-from-memory.c | 14 |
2 files changed, 9 insertions, 9 deletions
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index f6db301c..3d3edc5f 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,7 @@ +2014-12-19 Mark Wielaard <[email protected]> + + * elf-from-memory.c (handle_segment): Remove palign sanity check. + 2014-12-18 Mark Wielaard <[email protected]> * 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 df9fbe69..b35fac71 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; |
