The patch titled Subject: fs/binfmt_elf.c: coredump: allow process with empty address space to coredump has been added to the -mm tree. Its filename is elf-coredump-allow-process-with-empty-address-space-to-coredump.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/elf-coredump-allow-process-with-empty-address-space-to-coredump.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/elf-coredump-allow-process-with-empty-address-space-to-coredump.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Alexey Dobriyan <adobriyan@xxxxxxxxx> Subject: fs/binfmt_elf.c: coredump: allow process with empty address space to coredump Unmapping whole address space at once with munmap(0, (1ULL<<47) - 4096) or equivalent will create empty coredump. It is silly way to exit, however registers content may still be useful. The right to coredump is fundamental right of a process! Link: http://lkml.kernel.org/r/20191222150137.GA1277@avx2 Signed-off-by: Alexey Dobriyan <adobriyan@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- fs/binfmt_elf.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) --- a/fs/binfmt_elf.c~elf-coredump-allow-process-with-empty-address-space-to-coredump +++ a/fs/binfmt_elf.c @@ -1595,6 +1595,10 @@ static int fill_files_note(struct memelf if (size >= MAX_FILE_NOTE_SIZE) /* paranoia check */ return -EINVAL; size = round_up(size, PAGE_SIZE); + /* + * "size" can be 0 here legitimately. + * Let it ENOMEM and omit NT_FILE section which will be empty anyway. + */ data = kvmalloc(size, GFP_KERNEL); if (ZERO_OR_NULL_PTR(data)) return -ENOMEM; @@ -2257,9 +2261,13 @@ static int elf_core_dump(struct coredump dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE); + /* + * Zero vma process will get ZERO_SIZE_PTR here. + * Let coredump continue for register state at least. + */ vma_filesz = kvmalloc(array_size(sizeof(*vma_filesz), (segs - 1)), GFP_KERNEL); - if (ZERO_OR_NULL_PTR(vma_filesz)) + if (!vma_filesz) goto end_coredump; for (i = 0, vma = first_vma(current, gate_vma); vma != NULL; _ Patches currently in -mm which might be from adobriyan@xxxxxxxxx are ramfs-support-o_tmpfile.patch elf-smaller-code-generation-around-auxv-vector-fill.patch elf-fix-start_code-calculation.patch elf-dont-copy-elf-header-around.patch elf-better-codegen-around-current-mm.patch elf-make-bad_addr-unlikely.patch elf-coredump-allocate-core-elf-header-on-stack.patch elf-coredump-delete-duplicated-overflow-check.patch elf-coredump-allow-process-with-empty-address-space-to-coredump.patch execve-warn-if-process-starts-with-executable-stack.patch