History

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.

Catalin Marinas committed 3 years ago

Commit 19e183b1 parent 736eedc6 files · +14 −14Browse files

Unified · Split

6 files
  1. arch/arm64/kernel/elfcore.c +2 −2
  2. arch/ia64/kernel/elfcore.c +2 −2
  3. arch/x86/um/elfcore.c +2 −2
  4. fs/binfmt_elf.c +2 −2
  5. fs/binfmt_elf_fdpic.c +2 −2
  6. include/linux/elfcore.h +4 −4
arch/arm64/kernel/elfcore.c+2−2
@@ -76,7 +76,7 @@ static int mte_dump_tag_range(struct coredump_params *cprm, · 75 unmodified lines
76 return ret;76 return ret;
77}77}
78 78
79Elf_Half elf_core_extra_phdrs(void)79Elf_Half elf_core_extra_phdrs(struct coredump_params *cprm)
80{80{
81 struct vm_area_struct *vma;81 struct vm_area_struct *vma;
82 int vma_count = 0;82 int vma_count = 0;
@@ -113,7 +113,7 @@ int elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset) · 30 unmodified lines
113 return 1;113 return 1;
114}114}
115 115
116size_t elf_core_extra_data_size(void)116size_t elf_core_extra_data_size(struct coredump_params *cprm)
117{117{
118 struct vm_area_struct *vma;118 struct vm_area_struct *vma;
119 size_t data_size = 0;119 size_t data_size = 0;
arch/ia64/kernel/elfcore.c+2−2
@@ -7,7 +7,7 @@ · 6 unmodified lines
7#include <asm/elf.h>7#include <asm/elf.h>
8 8
9 9
10Elf64_Half elf_core_extra_phdrs(void)10Elf64_Half elf_core_extra_phdrs(struct coredump_params *cprm)
11{11{
12 return GATE_EHDR->e_phnum;12 return GATE_EHDR->e_phnum;
13}13}
@@ -60,7 +60,7 @@ int elf_core_write_extra_data(struct coredump_params *cprm) · 46 unmodified lines
60 return 1;60 return 1;
61}61}
62 62
63size_t elf_core_extra_data_size(void)63size_t elf_core_extra_data_size(struct coredump_params *cprm)
64{64{
65 const struct elf_phdr *const gate_phdrs =65 const struct elf_phdr *const gate_phdrs =
66 (const struct elf_phdr *) (GATE_ADDR + GATE_EHDR->e_phoff);66 (const struct elf_phdr *) (GATE_ADDR + GATE_EHDR->e_phoff);
arch/x86/um/elfcore.c+2−2
@@ -7,7 +7,7 @@ · 6 unmodified lines
7#include <asm/elf.h>7#include <asm/elf.h>
8 8
9 9
10Elf32_Half elf_core_extra_phdrs(void)10Elf32_Half elf_core_extra_phdrs(struct coredump_params *cprm)
11{11{
12 return vsyscall_ehdr ? (((struct elfhdr *)vsyscall_ehdr)->e_phnum) : 0;12 return vsyscall_ehdr ? (((struct elfhdr *)vsyscall_ehdr)->e_phnum) : 0;
13}13}
@@ -60,7 +60,7 @@ int elf_core_write_extra_data(struct coredump_params *cprm) · 46 unmodified lines
60 return 1;60 return 1;
61}61}
62 62
63size_t elf_core_extra_data_size(void)63size_t elf_core_extra_data_size(struct coredump_params *cprm)
64{64{
65 if ( vsyscall_ehdr ) {65 if ( vsyscall_ehdr ) {
66 const struct elfhdr *const ehdrp =66 const struct elfhdr *const ehdrp =
fs/binfmt_elf.c+2−2
@@ -2034,7 +2034,7 @@ static int elf_core_dump(struct coredump_params *cprm) · 2033 unmodified lines
2034 * The number of segs are recored into ELF header as 16bit value.2034 * The number of segs are recored into ELF header as 16bit value.
2035 * Please check DEFAULT_MAX_MAP_COUNT definition when you modify here.2035 * Please check DEFAULT_MAX_MAP_COUNT definition when you modify here.
2036 */2036 */
2037 segs = cprm->vma_count + elf_core_extra_phdrs();2037 segs = cprm->vma_count + elf_core_extra_phdrs(cprm);
2038 2038
2039 /* for notes section */2039 /* for notes section */
2040 segs++;2040 segs++;
@@ -2074,7 +2074,7 @@ static int elf_core_dump(struct coredump_params *cprm) · 33 unmodified lines
2074 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);2074 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
2075 2075
2076 offset += cprm->vma_data_size;2076 offset += cprm->vma_data_size;
2077 offset += elf_core_extra_data_size();2077 offset += elf_core_extra_data_size(cprm);
2078 e_shoff = offset;2078 e_shoff = offset;
2079 2079
2080 if (e_phnum == PN_XNUM) {2080 if (e_phnum == PN_XNUM) {
fs/binfmt_elf_fdpic.c+2−2
@@ -1509,7 +1509,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm) · 1508 unmodified lines
1509 tmp->next = thread_list;1509 tmp->next = thread_list;
1510 thread_list = tmp;1510 thread_list = tmp;
1511 1511
1512 segs = cprm->vma_count + elf_core_extra_phdrs();1512 segs = cprm->vma_count + elf_core_extra_phdrs(cprm);
1513 1513
1514 /* for notes section */1514 /* for notes section */
1515 segs++;1515 segs++;
@@ -1555,7 +1555,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm) · 39 unmodified lines
1555 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);1555 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
1556 1556
1557 offset += cprm->vma_data_size;1557 offset += cprm->vma_data_size;
1558 offset += elf_core_extra_data_size();1558 offset += elf_core_extra_data_size(cprm);
1559 e_shoff = offset;1559 e_shoff = offset;
1560 1560
1561 if (e_phnum == PN_XNUM) {1561 if (e_phnum == PN_XNUM) {
include/linux/elfcore.h+4−4
@@ -105,14 +105,14 @@ int elf_core_copy_task_fpregs(struct task_struct *t, elf_fpregset_t *fpu); · 104 unmodified lines
105 * Dumping its extra ELF program headers includes all the other information105 * Dumping its extra ELF program headers includes all the other information
106 * a debugger needs to easily find how the gate DSO was being used.106 * a debugger needs to easily find how the gate DSO was being used.
107 */107 */
108extern Elf_Half elf_core_extra_phdrs(void);108extern Elf_Half elf_core_extra_phdrs(struct coredump_params *cprm);
109extern int109extern int
110elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset);110elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset);
111extern int111extern int
112elf_core_write_extra_data(struct coredump_params *cprm);112elf_core_write_extra_data(struct coredump_params *cprm);
113extern size_t elf_core_extra_data_size(void);113extern size_t elf_core_extra_data_size(struct coredump_params *cprm);
114#else114#else
115static inline Elf_Half elf_core_extra_phdrs(void)115static inline Elf_Half elf_core_extra_phdrs(struct coredump_params *cprm)
116{116{
117 return 0;117 return 0;
118}118}
@@ -127,7 +127,7 @@ static inline int elf_core_write_extra_data(struct coredump_params *cprm) · 8 unmodified lines
127 return 1;127 return 1;
128}128}
129 129
130static inline size_t elf_core_extra_data_size(void)130static inline size_t elf_core_extra_data_size(struct coredump_params *cprm)
131{131{
132 return 0;132 return 0;
133}133}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t