aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2013-10-05 17:22:57 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2013-11-09 00:16:23 -0500
commit506f21c556c747bb07b893f146220ec45cda381b (patch)
tree314bda008996a302a73779d522c349eb174dc8b9
parentecc8c7725e6c21528329b34acae2a1d64b3af89b (diff)
switch elf_core_write_extra_phdrs() to dump_emit()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--arch/ia64/kernel/elfcore.c6
-rw-r--r--arch/x86/um/elfcore.c7
-rw-r--r--fs/binfmt_elf.c4
-rw-r--r--fs/binfmt_elf_fdpic.c4
-rw-r--r--include/linux/elfcore.h5
-rw-r--r--kernel/elfcore.c10
6 files changed, 15 insertions, 21 deletions
diff --git a/arch/ia64/kernel/elfcore.c b/arch/ia64/kernel/elfcore.c
index bac1639bc320..798ce543da4b 100644
--- a/arch/ia64/kernel/elfcore.c
+++ b/arch/ia64/kernel/elfcore.c
@@ -11,8 +11,7 @@ Elf64_Half elf_core_extra_phdrs(void)
11 return GATE_EHDR->e_phnum; 11 return GATE_EHDR->e_phnum;
12} 12}
13 13
14int elf_core_write_extra_phdrs(struct file *file, loff_t offset, size_t *size, 14int elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset)
15 unsigned long limit)
16{ 15{
17 const struct elf_phdr *const gate_phdrs = 16 const struct elf_phdr *const gate_phdrs =
18 (const struct elf_phdr *) (GATE_ADDR + GATE_EHDR->e_phoff); 17 (const struct elf_phdr *) (GATE_ADDR + GATE_EHDR->e_phoff);
@@ -35,8 +34,7 @@ int elf_core_write_extra_phdrs(struct file *file, loff_t offset, size_t *size,
35 phdr.p_offset += ofs; 34 phdr.p_offset += ofs;
36 } 35 }
37 phdr.p_paddr = 0; /* match other core phdrs */ 36 phdr.p_paddr = 0; /* match other core phdrs */
38 *size += sizeof(phdr); 37 if (!dump_emit(cprm, &phdr, sizeof(phdr)))
39 if (*size > limit || !dump_write(file, &phdr, sizeof(phdr)))
40 return 0; 38 return 0;
41 } 39 }
42 return 1; 40 return 1;
diff --git a/arch/x86/um/elfcore.c b/arch/x86/um/elfcore.c
index 6bb49b687c97..fc21f98efafe 100644
--- a/arch/x86/um/elfcore.c
+++ b/arch/x86/um/elfcore.c
@@ -11,8 +11,7 @@ Elf32_Half elf_core_extra_phdrs(void)
11 return vsyscall_ehdr ? (((struct elfhdr *)vsyscall_ehdr)->e_phnum) : 0; 11 return vsyscall_ehdr ? (((struct elfhdr *)vsyscall_ehdr)->e_phnum) : 0;
12} 12}
13 13
14int elf_core_write_extra_phdrs(struct file *file, loff_t offset, size_t *size, 14int elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset)
15 unsigned long limit)
16{ 15{
17 if ( vsyscall_ehdr ) { 16 if ( vsyscall_ehdr ) {
18 const struct elfhdr *const ehdrp = 17 const struct elfhdr *const ehdrp =
@@ -32,9 +31,7 @@ int elf_core_write_extra_phdrs(struct file *file, loff_t offset, size_t *size,
32 phdr.p_offset += ofs; 31 phdr.p_offset += ofs;
33 } 32 }
34 phdr.p_paddr = 0; /* match other core phdrs */ 33 phdr.p_paddr = 0; /* match other core phdrs */
35 *size += sizeof(phdr); 34 if (!dump_emit(cprm, &phdr, sizeof(phdr)))
36 if (*size > limit
37 || !dump_write(file, &phdr, sizeof(phdr)))
38 return 0; 35 return 0;
39 } 36 }
40 } 37 }
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 00fd9c969a27..35c4886dae2d 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -2152,11 +2152,11 @@ static int elf_core_dump(struct coredump_params *cprm)
2152 if (!dump_emit(cprm, &phdr, sizeof(phdr))) 2152 if (!dump_emit(cprm, &phdr, sizeof(phdr)))
2153 goto end_coredump; 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 goto end_coredump; 2157 goto end_coredump;
2159 2158
2159 size = cprm->written;
2160 cprm->written = foffset; /* will disappear */ 2160 cprm->written = foffset; /* will disappear */
2161 /* write out the notes section */ 2161 /* write out the notes section */
2162 if (!write_note_info(&info, cprm)) 2162 if (!write_note_info(&info, cprm))
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index ea4c6273b4a5..44db8b92121a 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -1791,9 +1791,11 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
1791 goto end_coredump; 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 goto end_coredump; 1796 goto end_coredump;
1796 1797
1798 size = cprm->written;
1797 /* write out the notes section */ 1799 /* write out the notes section */
1798 for (i = 0; i < numnote; i++) 1800 for (i = 0; i < numnote; i++)
1799 if (!writenote(notes + i, cprm->file, &foffset)) 1801 if (!writenote(notes + i, cprm->file, &foffset))
diff --git a/include/linux/elfcore.h b/include/linux/elfcore.h
index cdd3d13efce7..1b92a8c40624 100644
--- a/include/linux/elfcore.h
+++ b/include/linux/elfcore.h
@@ -6,6 +6,8 @@
6#include <asm/elf.h> 6#include <asm/elf.h>
7#include <uapi/linux/elfcore.h> 7#include <uapi/linux/elfcore.h>
8 8
9struct coredump_params;
10
9static inline void elf_core_copy_regs(elf_gregset_t *elfregs, struct pt_regs *regs) 11static inline void elf_core_copy_regs(elf_gregset_t *elfregs, struct pt_regs *regs)
10{ 12{
11#ifdef ELF_CORE_COPY_REGS 13#ifdef ELF_CORE_COPY_REGS
@@ -63,8 +65,7 @@ static inline int elf_core_copy_task_xfpregs(struct task_struct *t, elf_fpxregse
63 */ 65 */
64extern Elf_Half elf_core_extra_phdrs(void); 66extern Elf_Half elf_core_extra_phdrs(void);
65extern int 67extern int
66elf_core_write_extra_phdrs(struct file *file, loff_t offset, size_t *size, 68elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset);
67 unsigned long limit);
68extern int 69extern int
69elf_core_write_extra_data(struct file *file, size_t *size, unsigned long limit); 70elf_core_write_extra_data(struct file *file, size_t *size, unsigned long limit);
70extern size_t elf_core_extra_data_size(void); 71extern size_t elf_core_extra_data_size(void);
diff --git a/kernel/elfcore.c b/kernel/elfcore.c
index ff915efef66d..e556751d15d9 100644
--- a/kernel/elfcore.c
+++ b/kernel/elfcore.c
@@ -1,23 +1,19 @@
1#include <linux/elf.h> 1#include <linux/elf.h>
2#include <linux/fs.h> 2#include <linux/fs.h>
3#include <linux/mm.h> 3#include <linux/mm.h>
4 4#include <linux/binfmts.h>
5#include <asm/elf.h>
6
7 5
8Elf_Half __weak elf_core_extra_phdrs(void) 6Elf_Half __weak elf_core_extra_phdrs(void)
9{ 7{
10 return 0; 8 return 0;
11} 9}
12 10
13int __weak elf_core_write_extra_phdrs(struct file *file, loff_t offset, size_t *size, 11int __weak elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset)
14 unsigned long limit)
15{ 12{
16 return 1; 13 return 1;
17} 14}
18 15
19int __weak elf_core_write_extra_data(struct file *file, size_t *size, 16int __weak elf_core_write_extra_data(struct coredump_params *cprm)
20 unsigned long limit)
21{ 17{
22 return 1; 18 return 1;
23} 19}