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
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) · 30 unmodified lines
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+2−2
@@ -7,7 +7,7 @@ · 6 unmodified lines
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) · 46 unmodified lines
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+2−2
@@ -7,7 +7,7 @@ · 6 unmodified lines
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) · 46 unmodified lines
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+2−2
@@ -2034,7 +2034,7 @@ static int elf_core_dump(struct coredump_params *cprm) · 2033 unmodified lines
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) · 33 unmodified lines
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+2−2
@@ -1509,7 +1509,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm) · 1508 unmodified lines
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) · 39 unmodified lines
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+4−4
@@ -105,14 +105,14 @@ int elf_core_copy_task_fpregs(struct task_struct *t, elf_fpregset_t *fpu); · 104 unmodified lines
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) · 8 unmodified lines
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 }

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