Commit 506f21c556c747bb07b893f146220ec45cda381b
1 parent
ecc8c7725e
Exists in
master
and in
16 other branches
switch elf_core_write_extra_phdrs() to dump_emit()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Showing 6 changed files with 15 additions and 21 deletions Side-by-side Diff
arch/ia64/kernel/elfcore.c
| ... | ... | @@ -11,8 +11,7 @@ |
| 11 | 11 | return GATE_EHDR->e_phnum; |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | -int elf_core_write_extra_phdrs(struct file *file, loff_t offset, size_t *size, | |
| 15 | - unsigned long limit) | |
| 14 | +int elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset) | |
| 16 | 15 | { |
| 17 | 16 | const struct elf_phdr *const gate_phdrs = |
| 18 | 17 | (const struct elf_phdr *) (GATE_ADDR + GATE_EHDR->e_phoff); |
| ... | ... | @@ -35,8 +34,7 @@ |
| 35 | 34 | phdr.p_offset += ofs; |
| 36 | 35 | } |
| 37 | 36 | phdr.p_paddr = 0; /* match other core phdrs */ |
| 38 | - *size += sizeof(phdr); | |
| 39 | - if (*size > limit || !dump_write(file, &phdr, sizeof(phdr))) | |
| 37 | + if (!dump_emit(cprm, &phdr, sizeof(phdr))) | |
| 40 | 38 | return 0; |
| 41 | 39 | } |
| 42 | 40 | return 1; |
arch/x86/um/elfcore.c
| ... | ... | @@ -11,8 +11,7 @@ |
| 11 | 11 | return vsyscall_ehdr ? (((struct elfhdr *)vsyscall_ehdr)->e_phnum) : 0; |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | -int elf_core_write_extra_phdrs(struct file *file, loff_t offset, size_t *size, | |
| 15 | - unsigned long limit) | |
| 14 | +int elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset) | |
| 16 | 15 | { |
| 17 | 16 | if ( vsyscall_ehdr ) { |
| 18 | 17 | const struct elfhdr *const ehdrp = |
| ... | ... | @@ -32,9 +31,7 @@ |
| 32 | 31 | phdr.p_offset += ofs; |
| 33 | 32 | } |
| 34 | 33 | phdr.p_paddr = 0; /* match other core phdrs */ |
| 35 | - *size += sizeof(phdr); | |
| 36 | - if (*size > limit | |
| 37 | - || !dump_write(file, &phdr, sizeof(phdr))) | |
| 34 | + if (!dump_emit(cprm, &phdr, sizeof(phdr))) | |
| 38 | 35 | return 0; |
| 39 | 36 | } |
| 40 | 37 | } |
fs/binfmt_elf.c
| ... | ... | @@ -2152,11 +2152,11 @@ |
| 2152 | 2152 | if (!dump_emit(cprm, &phdr, sizeof(phdr))) |
| 2153 | 2153 | goto end_coredump; |
| 2154 | 2154 | } |
| 2155 | - size = cprm->written; | |
| 2156 | 2155 | |
| 2157 | - if (!elf_core_write_extra_phdrs(cprm->file, offset, &size, cprm->limit)) | |
| 2156 | + if (!elf_core_write_extra_phdrs(cprm, offset)) | |
| 2158 | 2157 | goto end_coredump; |
| 2159 | 2158 | |
| 2159 | + size = cprm->written; | |
| 2160 | 2160 | cprm->written = foffset; /* will disappear */ |
| 2161 | 2161 | /* write out the notes section */ |
| 2162 | 2162 | if (!write_note_info(&info, cprm)) |
fs/binfmt_elf_fdpic.c
| ... | ... | @@ -1791,9 +1791,11 @@ |
| 1791 | 1791 | goto end_coredump; |
| 1792 | 1792 | } |
| 1793 | 1793 | |
| 1794 | - if (!elf_core_write_extra_phdrs(cprm->file, offset, &size, cprm->limit)) | |
| 1794 | + cprm->written = size; | |
| 1795 | + if (!elf_core_write_extra_phdrs(cprm, offset)) | |
| 1795 | 1796 | goto end_coredump; |
| 1796 | 1797 | |
| 1798 | + size = cprm->written; | |
| 1797 | 1799 | /* write out the notes section */ |
| 1798 | 1800 | for (i = 0; i < numnote; i++) |
| 1799 | 1801 | if (!writenote(notes + i, cprm->file, &foffset)) |
include/linux/elfcore.h
| ... | ... | @@ -6,6 +6,8 @@ |
| 6 | 6 | #include <asm/elf.h> |
| 7 | 7 | #include <uapi/linux/elfcore.h> |
| 8 | 8 | |
| 9 | +struct coredump_params; | |
| 10 | + | |
| 9 | 11 | static inline void elf_core_copy_regs(elf_gregset_t *elfregs, struct pt_regs *regs) |
| 10 | 12 | { |
| 11 | 13 | #ifdef ELF_CORE_COPY_REGS |
| ... | ... | @@ -63,8 +65,7 @@ |
| 63 | 65 | */ |
| 64 | 66 | extern Elf_Half elf_core_extra_phdrs(void); |
| 65 | 67 | extern int |
| 66 | -elf_core_write_extra_phdrs(struct file *file, loff_t offset, size_t *size, | |
| 67 | - unsigned long limit); | |
| 68 | +elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset); | |
| 68 | 69 | extern int |
| 69 | 70 | elf_core_write_extra_data(struct file *file, size_t *size, unsigned long limit); |
| 70 | 71 | extern size_t elf_core_extra_data_size(void); |
kernel/elfcore.c
| 1 | 1 | #include <linux/elf.h> |
| 2 | 2 | #include <linux/fs.h> |
| 3 | 3 | #include <linux/mm.h> |
| 4 | +#include <linux/binfmts.h> | |
| 4 | 5 | |
| 5 | -#include <asm/elf.h> | |
| 6 | - | |
| 7 | - | |
| 8 | 6 | Elf_Half __weak elf_core_extra_phdrs(void) |
| 9 | 7 | { |
| 10 | 8 | return 0; |
| 11 | 9 | } |
| 12 | 10 | |
| 13 | -int __weak elf_core_write_extra_phdrs(struct file *file, loff_t offset, size_t *size, | |
| 14 | - unsigned long limit) | |
| 11 | +int __weak elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset) | |
| 15 | 12 | { |
| 16 | 13 | return 1; |
| 17 | 14 | } |
| 18 | 15 | |
| 19 | -int __weak elf_core_write_extra_data(struct file *file, size_t *size, | |
| 20 | - unsigned long limit) | |
| 16 | +int __weak elf_core_write_extra_data(struct coredump_params *cprm) | |
| 21 | 17 | { |
| 22 | 18 | return 1; |
| 23 | 19 | } |