Skip to content

Commit dd047ef

Browse files
committed
Merge tag 'execve-v6.14-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull core dumping fix from Kees Cook: - Only sort VMAs when core_sort_vma sysctl is set * tag 'execve-v6.14-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: coredump: Only sort VMAs when core_sort_vma sysctl is set
2 parents 6ceb634 + 39ec9ea commit dd047ef

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

Documentation/admin-guide/sysctl/kernel.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,17 @@ pid>/``).
212212
This value defaults to 0.
213213
214214

215+
core_sort_vma
216+
=============
217+
218+
The default coredump writes VMAs in address order. By setting
219+
``core_sort_vma`` to 1, VMAs will be written from smallest size
220+
to largest size. This is known to break at least elfutils, but
221+
can be handy when dealing with very large (and truncated)
222+
coredumps where the more useful debugging details are included
223+
in the smaller VMAs.
224+
225+
215226
core_uses_pid
216227
=============
217228

fs/coredump.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ static void free_vma_snapshot(struct coredump_params *cprm);
6363

6464
static int core_uses_pid;
6565
static unsigned int core_pipe_limit;
66+
static unsigned int core_sort_vma;
6667
static char core_pattern[CORENAME_MAX_SIZE] = "core";
6768
static int core_name_size = CORENAME_MAX_SIZE;
6869
unsigned int core_file_note_size_limit = CORE_FILE_NOTE_SIZE_DEFAULT;
@@ -1026,6 +1027,15 @@ static const struct ctl_table coredump_sysctls[] = {
10261027
.extra1 = (unsigned int *)&core_file_note_size_min,
10271028
.extra2 = (unsigned int *)&core_file_note_size_max,
10281029
},
1030+
{
1031+
.procname = "core_sort_vma",
1032+
.data = &core_sort_vma,
1033+
.maxlen = sizeof(int),
1034+
.mode = 0644,
1035+
.proc_handler = proc_douintvec_minmax,
1036+
.extra1 = SYSCTL_ZERO,
1037+
.extra2 = SYSCTL_ONE,
1038+
},
10291039
};
10301040

10311041
static int __init init_fs_coredump_sysctls(void)
@@ -1256,8 +1266,9 @@ static bool dump_vma_snapshot(struct coredump_params *cprm)
12561266
cprm->vma_data_size += m->dump_size;
12571267
}
12581268

1259-
sort(cprm->vma_meta, cprm->vma_count, sizeof(*cprm->vma_meta),
1260-
cmp_vma_size, NULL);
1269+
if (core_sort_vma)
1270+
sort(cprm->vma_meta, cprm->vma_count, sizeof(*cprm->vma_meta),
1271+
cmp_vma_size, NULL);
12611272

12621273
return true;
12631274
}

0 commit comments

Comments
 (0)