mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-04-13 09:59:31 +00:00
coredump: Only sort VMAs when core_sort_vma sysctl is set
The sorting of VMAs by size in commit7d442a33bf
("binfmt_elf: Dump smaller VMAs first in ELF cores") breaks elfutils[1]. Instead, sort based on the setting of the new sysctl, core_sort_vma, which defaults to 0, no sorting. Reported-by: Michael Stapelberg <michael@stapelberg.ch> Closes: https://lore.kernel.org/all/20250218085407.61126-1-michael@stapelberg.de/ [1] Fixes:7d442a33bf
("binfmt_elf: Dump smaller VMAs first in ELF cores") Signed-off-by: Kees Cook <kees@kernel.org>
This commit is contained in:
parent
a64dcfb451
commit
39ec9eaaa1
2 changed files with 24 additions and 2 deletions
|
@ -212,6 +212,17 @@ pid>/``).
|
||||||
This value defaults to 0.
|
This value defaults to 0.
|
||||||
|
|
||||||
|
|
||||||
|
core_sort_vma
|
||||||
|
=============
|
||||||
|
|
||||||
|
The default coredump writes VMAs in address order. By setting
|
||||||
|
``core_sort_vma`` to 1, VMAs will be written from smallest size
|
||||||
|
to largest size. This is known to break at least elfutils, but
|
||||||
|
can be handy when dealing with very large (and truncated)
|
||||||
|
coredumps where the more useful debugging details are included
|
||||||
|
in the smaller VMAs.
|
||||||
|
|
||||||
|
|
||||||
core_uses_pid
|
core_uses_pid
|
||||||
=============
|
=============
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,7 @@ static void free_vma_snapshot(struct coredump_params *cprm);
|
||||||
|
|
||||||
static int core_uses_pid;
|
static int core_uses_pid;
|
||||||
static unsigned int core_pipe_limit;
|
static unsigned int core_pipe_limit;
|
||||||
|
static unsigned int core_sort_vma;
|
||||||
static char core_pattern[CORENAME_MAX_SIZE] = "core";
|
static char core_pattern[CORENAME_MAX_SIZE] = "core";
|
||||||
static int core_name_size = CORENAME_MAX_SIZE;
|
static int core_name_size = CORENAME_MAX_SIZE;
|
||||||
unsigned int core_file_note_size_limit = CORE_FILE_NOTE_SIZE_DEFAULT;
|
unsigned int core_file_note_size_limit = CORE_FILE_NOTE_SIZE_DEFAULT;
|
||||||
|
@ -1026,6 +1027,15 @@ static const struct ctl_table coredump_sysctls[] = {
|
||||||
.extra1 = (unsigned int *)&core_file_note_size_min,
|
.extra1 = (unsigned int *)&core_file_note_size_min,
|
||||||
.extra2 = (unsigned int *)&core_file_note_size_max,
|
.extra2 = (unsigned int *)&core_file_note_size_max,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.procname = "core_sort_vma",
|
||||||
|
.data = &core_sort_vma,
|
||||||
|
.maxlen = sizeof(int),
|
||||||
|
.mode = 0644,
|
||||||
|
.proc_handler = proc_douintvec_minmax,
|
||||||
|
.extra1 = SYSCTL_ZERO,
|
||||||
|
.extra2 = SYSCTL_ONE,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static int __init init_fs_coredump_sysctls(void)
|
static int __init init_fs_coredump_sysctls(void)
|
||||||
|
@ -1256,6 +1266,7 @@ static bool dump_vma_snapshot(struct coredump_params *cprm)
|
||||||
cprm->vma_data_size += m->dump_size;
|
cprm->vma_data_size += m->dump_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (core_sort_vma)
|
||||||
sort(cprm->vma_meta, cprm->vma_count, sizeof(*cprm->vma_meta),
|
sort(cprm->vma_meta, cprm->vma_count, sizeof(*cprm->vma_meta),
|
||||||
cmp_vma_size, NULL);
|
cmp_vma_size, NULL);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue