Commit ec0063b4 authored by Suleiman Souhlal's avatar Suleiman Souhlal Committed by Linus Torvalds

[PATCH] x86_64: Don't write out segments from vsyscall32 DSO if it is not mapped

It's possible to get an invalid page fault in kernel mode when we try to
write out segments from vsyscall32 when dumping core for a 32bit process if
the vsyscall32 DSO is not mapped in its address space (which can happen if,
for example, ulimit -v 100 is run).
Signed-off-by: default avatarSuleiman Souhlal <suleiman@google.com>
Signed-off-by: default avatarAndi Kleen <ak@suse.de>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 01ebb77b
...@@ -73,12 +73,14 @@ typedef elf_greg_t elf_gregset_t[ELF_NGREG]; ...@@ -73,12 +73,14 @@ typedef elf_greg_t elf_gregset_t[ELF_NGREG];
* Dumping its extra ELF program headers includes all the other information * Dumping its extra ELF program headers includes all the other information
* a debugger needs to easily find how the vsyscall DSO was being used. * a debugger needs to easily find how the vsyscall DSO was being used.
*/ */
#define ELF_CORE_EXTRA_PHDRS (VSYSCALL32_EHDR->e_phnum) #define ELF_CORE_EXTRA_PHDRS (find_vma(current->mm, VSYSCALL32_BASE) ? \
(VSYSCALL32_EHDR->e_phnum) : 0)
#define ELF_CORE_WRITE_EXTRA_PHDRS \ #define ELF_CORE_WRITE_EXTRA_PHDRS \
do { \ do { \
if (find_vma(current->mm, VSYSCALL32_BASE)) { \
const struct elf32_phdr *const vsyscall_phdrs = \ const struct elf32_phdr *const vsyscall_phdrs = \
(const struct elf32_phdr *) (VSYSCALL32_BASE \ (const struct elf32_phdr *) (VSYSCALL32_BASE \
+ VSYSCALL32_EHDR->e_phoff); \ + VSYSCALL32_EHDR->e_phoff);\
int i; \ int i; \
Elf32_Off ofs = 0; \ Elf32_Off ofs = 0; \
for (i = 0; i < VSYSCALL32_EHDR->e_phnum; ++i) { \ for (i = 0; i < VSYSCALL32_EHDR->e_phnum; ++i) { \
...@@ -95,18 +97,21 @@ do { \ ...@@ -95,18 +97,21 @@ do { \
phdr.p_paddr = 0; /* match other core phdrs */ \ phdr.p_paddr = 0; /* match other core phdrs */ \
DUMP_WRITE(&phdr, sizeof(phdr)); \ DUMP_WRITE(&phdr, sizeof(phdr)); \
} \ } \
} \
} while (0) } while (0)
#define ELF_CORE_WRITE_EXTRA_DATA \ #define ELF_CORE_WRITE_EXTRA_DATA \
do { \ do { \
if (find_vma(current->mm, VSYSCALL32_BASE)) { \
const struct elf32_phdr *const vsyscall_phdrs = \ const struct elf32_phdr *const vsyscall_phdrs = \
(const struct elf32_phdr *) (VSYSCALL32_BASE \ (const struct elf32_phdr *) (VSYSCALL32_BASE \
+ VSYSCALL32_EHDR->e_phoff); \ + VSYSCALL32_EHDR->e_phoff); \
int i; \ int i; \
for (i = 0; i < VSYSCALL32_EHDR->e_phnum; ++i) { \ for (i = 0; i < VSYSCALL32_EHDR->e_phnum; ++i) { \
if (vsyscall_phdrs[i].p_type == PT_LOAD) \ if (vsyscall_phdrs[i].p_type == PT_LOAD) \
DUMP_WRITE((void *) (u64) vsyscall_phdrs[i].p_vaddr, \ DUMP_WRITE((void *) (u64) vsyscall_phdrs[i].p_vaddr,\
PAGE_ALIGN(vsyscall_phdrs[i].p_memsz)); \ PAGE_ALIGN(vsyscall_phdrs[i].p_memsz)); \
} \ } \
} \
} while (0) } while (0)
struct elf_siginfo struct elf_siginfo
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment