diff options
author | Jann Horn <jannh@google.com> | 2020-10-16 05:12:46 +0200 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2020-10-16 20:11:21 +0200 |
commit | afc63a97b764bc5a715762d0d9cc9785c2ef4e75 (patch) | |
tree | 7ceaeef4bab7d4bea18545e9a49ad7856ec7f649 /fs/binfmt_elf.c | |
parent | coredump: let dump_emit() bail out on short writes (diff) | |
download | linux-afc63a97b764bc5a715762d0d9cc9785c2ef4e75.tar.xz linux-afc63a97b764bc5a715762d0d9cc9785c2ef4e75.zip |
coredump: refactor page range dumping into common helper
Both fs/binfmt_elf.c and fs/binfmt_elf_fdpic.c need to dump ranges of
pages into the coredump file. Extract that logic into a common helper.
Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: "Eric W . Biederman" <ebiederm@xmission.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Link: http://lkml.kernel.org/r/20200827114932.3572699-4-jannh@google.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/binfmt_elf.c')
-rw-r--r-- | fs/binfmt_elf.c | 22 |
1 files changed, 2 insertions, 20 deletions
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 96370e3e3687..cf956edf05ef 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -2444,26 +2444,8 @@ static int elf_core_dump(struct coredump_params *cprm) for (i = 0, vma = first_vma(current, gate_vma); vma != NULL; vma = next_vma(vma, gate_vma)) { - unsigned long addr; - unsigned long end; - - end = vma->vm_start + vma_filesz[i++]; - - for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) { - struct page *page; - int stop; - - page = get_dump_page(addr); - if (page) { - void *kaddr = kmap(page); - stop = !dump_emit(cprm, kaddr, PAGE_SIZE); - kunmap(page); - put_page(page); - } else - stop = !dump_skip(cprm, PAGE_SIZE); - if (stop) - goto end_coredump; - } + if (!dump_user_range(cprm, vma->vm_start, vma_filesz[i++])) + goto end_coredump; } dump_truncate(cprm); |