Skip to content

Commit a02ada1

Browse files
committed
Merge: coredump: Only sort VMAs when core_sort_vma sysctl is set [rhel-10.2]
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/1199 JIRA: https://issues.redhat.com/browse/RHEL-96077 - coredump: Only sort VMAs when core_sort_vma sysctl is set (Herton R. Krzesinski) [[RHEL-96077](https://issues.redhat.com/browse/RHEL-96077)] Signed-off-by: Herton R. Krzesinski <herton@redhat.com> Approved-by: Waiman Long <longman@redhat.com> Approved-by: Brian Foster <bfoster@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Scott Weaver <scweaver@redhat.com>
2 parents c8f19bb + 003904b commit a02ada1

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;
@@ -1025,6 +1026,15 @@ static struct ctl_table coredump_sysctls[] = {
10251026
.extra1 = (unsigned int *)&core_file_note_size_min,
10261027
.extra2 = (unsigned int *)&core_file_note_size_max,
10271028
},
1029+
{
1030+
.procname = "core_sort_vma",
1031+
.data = &core_sort_vma,
1032+
.maxlen = sizeof(int),
1033+
.mode = 0644,
1034+
.proc_handler = proc_douintvec_minmax,
1035+
.extra1 = SYSCTL_ZERO,
1036+
.extra2 = SYSCTL_ONE,
1037+
},
10281038
};
10291039

10301040
static int __init init_fs_coredump_sysctls(void)
@@ -1255,8 +1265,9 @@ static bool dump_vma_snapshot(struct coredump_params *cprm)
12551265
cprm->vma_data_size += m->dump_size;
12561266
}
12571267

1258-
sort(cprm->vma_meta, cprm->vma_count, sizeof(*cprm->vma_meta),
1259-
cmp_vma_size, NULL);
1268+
if (core_sort_vma)
1269+
sort(cprm->vma_meta, cprm->vma_count, sizeof(*cprm->vma_meta),
1270+
cmp_vma_size, NULL);
12601271

12611272
return true;
12621273
}

0 commit comments

Comments
 (0)