Skip to content

Commit 506f21c

Browse files
author
Al Viro
committed
switch elf_core_write_extra_phdrs() to dump_emit()
Signed-off-by: Al Viro <[email protected]>
1 parent ecc8c77 commit 506f21c

File tree

6 files changed

+15
-21
lines changed

6 files changed

+15
-21
lines changed

arch/ia64/kernel/elfcore.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ Elf64_Half elf_core_extra_phdrs(void)
1111
return GATE_EHDR->e_phnum;
1212
}
1313

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)
1615
{
1716
const struct elf_phdr *const gate_phdrs =
1817
(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,
3534
phdr.p_offset += ofs;
3635
}
3736
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)))
4038
return 0;
4139
}
4240
return 1;

arch/x86/um/elfcore.c

+2-5
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ Elf32_Half elf_core_extra_phdrs(void)
1111
return vsyscall_ehdr ? (((struct elfhdr *)vsyscall_ehdr)->e_phnum) : 0;
1212
}
1313

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)
1615
{
1716
if ( vsyscall_ehdr ) {
1817
const struct elfhdr *const ehdrp =
@@ -32,9 +31,7 @@ int elf_core_write_extra_phdrs(struct file *file, loff_t offset, size_t *size,
3231
phdr.p_offset += ofs;
3332
}
3433
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)))
3835
return 0;
3936
}
4037
}

fs/binfmt_elf.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2152,11 +2152,11 @@ static int elf_core_dump(struct coredump_params *cprm)
21522152
if (!dump_emit(cprm, &phdr, sizeof(phdr)))
21532153
goto end_coredump;
21542154
}
2155-
size = cprm->written;
21562155

2157-
if (!elf_core_write_extra_phdrs(cprm->file, offset, &size, cprm->limit))
2156+
if (!elf_core_write_extra_phdrs(cprm, offset))
21582157
goto end_coredump;
21592158

2159+
size = cprm->written;
21602160
cprm->written = foffset; /* will disappear */
21612161
/* write out the notes section */
21622162
if (!write_note_info(&info, cprm))

fs/binfmt_elf_fdpic.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -1791,9 +1791,11 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
17911791
goto end_coredump;
17921792
}
17931793

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))
17951796
goto end_coredump;
17961797

1798+
size = cprm->written;
17971799
/* write out the notes section */
17981800
for (i = 0; i < numnote; i++)
17991801
if (!writenote(notes + i, cprm->file, &foffset))

include/linux/elfcore.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include <asm/elf.h>
77
#include <uapi/linux/elfcore.h>
88

9+
struct coredump_params;
10+
911
static inline void elf_core_copy_regs(elf_gregset_t *elfregs, struct pt_regs *regs)
1012
{
1113
#ifdef ELF_CORE_COPY_REGS
@@ -63,8 +65,7 @@ static inline int elf_core_copy_task_xfpregs(struct task_struct *t, elf_fpxregse
6365
*/
6466
extern Elf_Half elf_core_extra_phdrs(void);
6567
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);
6869
extern int
6970
elf_core_write_extra_data(struct file *file, size_t *size, unsigned long limit);
7071
extern size_t elf_core_extra_data_size(void);

kernel/elfcore.c

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
#include <linux/elf.h>
22
#include <linux/fs.h>
33
#include <linux/mm.h>
4-
5-
#include <asm/elf.h>
6-
4+
#include <linux/binfmts.h>
75

86
Elf_Half __weak elf_core_extra_phdrs(void)
97
{
108
return 0;
119
}
1210

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)
1512
{
1613
return 1;
1714
}
1815

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)
2117
{
2218
return 1;
2319
}

0 commit comments

Comments
 (0)