Skip to content

Commit 19e183b

Browse files
ctmarinaswilldeacon
authored andcommitted
elfcore: Add a cprm parameter to elf_core_extra_{phdrs,data_size}
A subsequent fix for arm64 will use this parameter to parse the vma information from the snapshot created by dump_vma_snapshot() rather than traversing the vma list without the mmap_lock. Fixes: 6dd8b1a ("arm64: mte: Dump the MTE tags in the core file") Cc: <[email protected]> # 5.18.x Signed-off-by: Catalin Marinas <[email protected]> Reported-by: Seth Jenkins <[email protected]> Suggested-by: Seth Jenkins <[email protected]> Cc: Will Deacon <[email protected]> Cc: Eric Biederman <[email protected]> Cc: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 736eedc commit 19e183b

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

arch/arm64/kernel/elfcore.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ static int mte_dump_tag_range(struct coredump_params *cprm,
7676
return ret;
7777
}
7878

79-
Elf_Half elf_core_extra_phdrs(void)
79+
Elf_Half elf_core_extra_phdrs(struct coredump_params *cprm)
8080
{
8181
struct vm_area_struct *vma;
8282
int vma_count = 0;
@@ -113,7 +113,7 @@ int elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset)
113113
return 1;
114114
}
115115

116-
size_t elf_core_extra_data_size(void)
116+
size_t elf_core_extra_data_size(struct coredump_params *cprm)
117117
{
118118
struct vm_area_struct *vma;
119119
size_t data_size = 0;

arch/ia64/kernel/elfcore.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <asm/elf.h>
88

99

10-
Elf64_Half elf_core_extra_phdrs(void)
10+
Elf64_Half elf_core_extra_phdrs(struct coredump_params *cprm)
1111
{
1212
return GATE_EHDR->e_phnum;
1313
}
@@ -60,7 +60,7 @@ int elf_core_write_extra_data(struct coredump_params *cprm)
6060
return 1;
6161
}
6262

63-
size_t elf_core_extra_data_size(void)
63+
size_t elf_core_extra_data_size(struct coredump_params *cprm)
6464
{
6565
const struct elf_phdr *const gate_phdrs =
6666
(const struct elf_phdr *) (GATE_ADDR + GATE_EHDR->e_phoff);

arch/x86/um/elfcore.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <asm/elf.h>
88

99

10-
Elf32_Half elf_core_extra_phdrs(void)
10+
Elf32_Half elf_core_extra_phdrs(struct coredump_params *cprm)
1111
{
1212
return vsyscall_ehdr ? (((struct elfhdr *)vsyscall_ehdr)->e_phnum) : 0;
1313
}
@@ -60,7 +60,7 @@ int elf_core_write_extra_data(struct coredump_params *cprm)
6060
return 1;
6161
}
6262

63-
size_t elf_core_extra_data_size(void)
63+
size_t elf_core_extra_data_size(struct coredump_params *cprm)
6464
{
6565
if ( vsyscall_ehdr ) {
6666
const struct elfhdr *const ehdrp =

fs/binfmt_elf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2034,7 +2034,7 @@ static int elf_core_dump(struct coredump_params *cprm)
20342034
* The number of segs are recored into ELF header as 16bit value.
20352035
* Please check DEFAULT_MAX_MAP_COUNT definition when you modify here.
20362036
*/
2037-
segs = cprm->vma_count + elf_core_extra_phdrs();
2037+
segs = cprm->vma_count + elf_core_extra_phdrs(cprm);
20382038

20392039
/* for notes section */
20402040
segs++;
@@ -2074,7 +2074,7 @@ static int elf_core_dump(struct coredump_params *cprm)
20742074
dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
20752075

20762076
offset += cprm->vma_data_size;
2077-
offset += elf_core_extra_data_size();
2077+
offset += elf_core_extra_data_size(cprm);
20782078
e_shoff = offset;
20792079

20802080
if (e_phnum == PN_XNUM) {

fs/binfmt_elf_fdpic.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,7 +1509,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
15091509
tmp->next = thread_list;
15101510
thread_list = tmp;
15111511

1512-
segs = cprm->vma_count + elf_core_extra_phdrs();
1512+
segs = cprm->vma_count + elf_core_extra_phdrs(cprm);
15131513

15141514
/* for notes section */
15151515
segs++;
@@ -1555,7 +1555,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
15551555
dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
15561556

15571557
offset += cprm->vma_data_size;
1558-
offset += elf_core_extra_data_size();
1558+
offset += elf_core_extra_data_size(cprm);
15591559
e_shoff = offset;
15601560

15611561
if (e_phnum == PN_XNUM) {

include/linux/elfcore.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@ int elf_core_copy_task_fpregs(struct task_struct *t, elf_fpregset_t *fpu);
105105
* Dumping its extra ELF program headers includes all the other information
106106
* a debugger needs to easily find how the gate DSO was being used.
107107
*/
108-
extern Elf_Half elf_core_extra_phdrs(void);
108+
extern Elf_Half elf_core_extra_phdrs(struct coredump_params *cprm);
109109
extern int
110110
elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset);
111111
extern int
112112
elf_core_write_extra_data(struct coredump_params *cprm);
113-
extern size_t elf_core_extra_data_size(void);
113+
extern size_t elf_core_extra_data_size(struct coredump_params *cprm);
114114
#else
115-
static inline Elf_Half elf_core_extra_phdrs(void)
115+
static inline Elf_Half elf_core_extra_phdrs(struct coredump_params *cprm)
116116
{
117117
return 0;
118118
}
@@ -127,7 +127,7 @@ static inline int elf_core_write_extra_data(struct coredump_params *cprm)
127127
return 1;
128128
}
129129

130-
static inline size_t elf_core_extra_data_size(void)
130+
static inline size_t elf_core_extra_data_size(struct coredump_params *cprm)
131131
{
132132
return 0;
133133
}

0 commit comments

Comments
 (0)