elfcore: Add a cprm parameter to elf_core_extra_{phdrs,data_size}
commit 19e183b54528f11fafeca60fc6d0821e29ff281e upstream. 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: 6dd8b1a0b6cb ("arm64: mte: Dump the MTE tags in the core file") Cc: <stable@vger.kernel.org> # 5.18.x Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Reported-by: Seth Jenkins <sethjenkins@google.com> Suggested-by: Seth Jenkins <sethjenkins@google.com> Cc: Will Deacon <will@kernel.org> Cc: Eric Biederman <ebiederm@xmission.com> Cc: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/r/20221222181251.1345752-3-catalin.marinas@arm.com Signed-off-by: Will Deacon <will@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
5fc5cdee8e
commit
80a82f6eb3
arch
fs
include/linux
@ -75,7 +75,7 @@ static int mte_dump_tag_range(struct coredump_params *cprm,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Elf_Half elf_core_extra_phdrs(void)
|
Elf_Half elf_core_extra_phdrs(struct coredump_params *cprm)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct core_vma_metadata *m;
|
struct core_vma_metadata *m;
|
||||||
@ -112,7 +112,7 @@ int elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t elf_core_extra_data_size(void)
|
size_t elf_core_extra_data_size(struct coredump_params *cprm)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct core_vma_metadata *m;
|
struct core_vma_metadata *m;
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <asm/elf.h>
|
#include <asm/elf.h>
|
||||||
|
|
||||||
|
|
||||||
Elf64_Half elf_core_extra_phdrs(void)
|
Elf64_Half elf_core_extra_phdrs(struct coredump_params *cprm)
|
||||||
{
|
{
|
||||||
return GATE_EHDR->e_phnum;
|
return GATE_EHDR->e_phnum;
|
||||||
}
|
}
|
||||||
@ -60,7 +60,7 @@ int elf_core_write_extra_data(struct coredump_params *cprm)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t elf_core_extra_data_size(void)
|
size_t elf_core_extra_data_size(struct coredump_params *cprm)
|
||||||
{
|
{
|
||||||
const struct elf_phdr *const gate_phdrs =
|
const struct elf_phdr *const gate_phdrs =
|
||||||
(const struct elf_phdr *) (GATE_ADDR + GATE_EHDR->e_phoff);
|
(const struct elf_phdr *) (GATE_ADDR + GATE_EHDR->e_phoff);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <asm/elf.h>
|
#include <asm/elf.h>
|
||||||
|
|
||||||
|
|
||||||
Elf32_Half elf_core_extra_phdrs(void)
|
Elf32_Half elf_core_extra_phdrs(struct coredump_params *cprm)
|
||||||
{
|
{
|
||||||
return vsyscall_ehdr ? (((struct elfhdr *)vsyscall_ehdr)->e_phnum) : 0;
|
return vsyscall_ehdr ? (((struct elfhdr *)vsyscall_ehdr)->e_phnum) : 0;
|
||||||
}
|
}
|
||||||
@ -60,7 +60,7 @@ int elf_core_write_extra_data(struct coredump_params *cprm)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t elf_core_extra_data_size(void)
|
size_t elf_core_extra_data_size(struct coredump_params *cprm)
|
||||||
{
|
{
|
||||||
if ( vsyscall_ehdr ) {
|
if ( vsyscall_ehdr ) {
|
||||||
const struct elfhdr *const ehdrp =
|
const struct elfhdr *const ehdrp =
|
||||||
|
@ -2209,7 +2209,7 @@ static int elf_core_dump(struct coredump_params *cprm)
|
|||||||
* The number of segs are recored into ELF header as 16bit value.
|
* The number of segs are recored into ELF header as 16bit value.
|
||||||
* Please check DEFAULT_MAX_MAP_COUNT definition when you modify here.
|
* Please check DEFAULT_MAX_MAP_COUNT definition when you modify here.
|
||||||
*/
|
*/
|
||||||
segs = cprm->vma_count + elf_core_extra_phdrs();
|
segs = cprm->vma_count + elf_core_extra_phdrs(cprm);
|
||||||
|
|
||||||
/* for notes section */
|
/* for notes section */
|
||||||
segs++;
|
segs++;
|
||||||
@ -2249,7 +2249,7 @@ static int elf_core_dump(struct coredump_params *cprm)
|
|||||||
dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
|
dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
|
||||||
|
|
||||||
offset += cprm->vma_data_size;
|
offset += cprm->vma_data_size;
|
||||||
offset += elf_core_extra_data_size();
|
offset += elf_core_extra_data_size(cprm);
|
||||||
e_shoff = offset;
|
e_shoff = offset;
|
||||||
|
|
||||||
if (e_phnum == PN_XNUM) {
|
if (e_phnum == PN_XNUM) {
|
||||||
|
@ -1509,7 +1509,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
|
|||||||
tmp->next = thread_list;
|
tmp->next = thread_list;
|
||||||
thread_list = tmp;
|
thread_list = tmp;
|
||||||
|
|
||||||
segs = cprm->vma_count + elf_core_extra_phdrs();
|
segs = cprm->vma_count + elf_core_extra_phdrs(cprm);
|
||||||
|
|
||||||
/* for notes section */
|
/* for notes section */
|
||||||
segs++;
|
segs++;
|
||||||
@ -1555,7 +1555,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
|
|||||||
dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
|
dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
|
||||||
|
|
||||||
offset += cprm->vma_data_size;
|
offset += cprm->vma_data_size;
|
||||||
offset += elf_core_extra_data_size();
|
offset += elf_core_extra_data_size(cprm);
|
||||||
e_shoff = offset;
|
e_shoff = offset;
|
||||||
|
|
||||||
if (e_phnum == PN_XNUM) {
|
if (e_phnum == PN_XNUM) {
|
||||||
|
@ -114,14 +114,14 @@ static inline int elf_core_copy_task_fpregs(struct task_struct *t, struct pt_reg
|
|||||||
* Dumping its extra ELF program headers includes all the other information
|
* Dumping its extra ELF program headers includes all the other information
|
||||||
* a debugger needs to easily find how the gate DSO was being used.
|
* a debugger needs to easily find how the gate DSO was being used.
|
||||||
*/
|
*/
|
||||||
extern Elf_Half elf_core_extra_phdrs(void);
|
extern Elf_Half elf_core_extra_phdrs(struct coredump_params *cprm);
|
||||||
extern int
|
extern int
|
||||||
elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset);
|
elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset);
|
||||||
extern int
|
extern int
|
||||||
elf_core_write_extra_data(struct coredump_params *cprm);
|
elf_core_write_extra_data(struct coredump_params *cprm);
|
||||||
extern size_t elf_core_extra_data_size(void);
|
extern size_t elf_core_extra_data_size(struct coredump_params *cprm);
|
||||||
#else
|
#else
|
||||||
static inline Elf_Half elf_core_extra_phdrs(void)
|
static inline Elf_Half elf_core_extra_phdrs(struct coredump_params *cprm)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -136,7 +136,7 @@ static inline int elf_core_write_extra_data(struct coredump_params *cprm)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline size_t elf_core_extra_data_size(void)
|
static inline size_t elf_core_extra_data_size(struct coredump_params *cprm)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user