Commit 13046ece authored by Al Viro's avatar Al Viro

binfmt_elf: convert writing actual dump pages to dump_emit()

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent aa3e7eaf
...@@ -2093,7 +2093,6 @@ static int elf_core_dump(struct coredump_params *cprm) ...@@ -2093,7 +2093,6 @@ static int elf_core_dump(struct coredump_params *cprm)
offset += sizeof(*elf); /* Elf header */ offset += sizeof(*elf); /* Elf header */
offset += segs * sizeof(struct elf_phdr); /* Program headers */ offset += segs * sizeof(struct elf_phdr); /* Program headers */
foffset = offset;
/* Write notes phdr entry */ /* Write notes phdr entry */
{ {
...@@ -2157,7 +2156,6 @@ static int elf_core_dump(struct coredump_params *cprm) ...@@ -2157,7 +2156,6 @@ static int elf_core_dump(struct coredump_params *cprm)
goto end_coredump; goto end_coredump;
size = cprm->written; size = cprm->written;
cprm->written = foffset; /* will disappear */
/* write out the notes section */ /* write out the notes section */
if (!write_note_info(&info, cprm)) if (!write_note_info(&info, cprm))
goto end_coredump; goto end_coredump;
...@@ -2170,6 +2168,7 @@ static int elf_core_dump(struct coredump_params *cprm) ...@@ -2170,6 +2168,7 @@ static int elf_core_dump(struct coredump_params *cprm)
if (!dump_seek(cprm->file, dataoff - foffset)) if (!dump_seek(cprm->file, dataoff - foffset))
goto end_coredump; goto end_coredump;
cprm->written = size;
for (vma = first_vma(current, gate_vma); vma != NULL; for (vma = first_vma(current, gate_vma); vma != NULL;
vma = next_vma(vma, gate_vma)) { vma = next_vma(vma, gate_vma)) {
unsigned long addr; unsigned long addr;
...@@ -2184,9 +2183,7 @@ static int elf_core_dump(struct coredump_params *cprm) ...@@ -2184,9 +2183,7 @@ static int elf_core_dump(struct coredump_params *cprm)
page = get_dump_page(addr); page = get_dump_page(addr);
if (page) { if (page) {
void *kaddr = kmap(page); void *kaddr = kmap(page);
stop = ((size += PAGE_SIZE) > cprm->limit) || stop = !dump_emit(cprm, kaddr, PAGE_SIZE);
!dump_write(cprm->file, kaddr,
PAGE_SIZE);
kunmap(page); kunmap(page);
page_cache_release(page); page_cache_release(page);
} else } else
...@@ -2196,16 +2193,11 @@ static int elf_core_dump(struct coredump_params *cprm) ...@@ -2196,16 +2193,11 @@ static int elf_core_dump(struct coredump_params *cprm)
} }
} }
cprm->written = size;
if (!elf_core_write_extra_data(cprm)) if (!elf_core_write_extra_data(cprm))
goto end_coredump; goto end_coredump;
size = cprm->written;
if (e_phnum == PN_XNUM) { if (e_phnum == PN_XNUM) {
size += sizeof(*shdr4extnum); if (!dump_emit(cprm, shdr4extnum, sizeof(*shdr4extnum)))
if (size > cprm->limit
|| !dump_write(cprm->file, shdr4extnum,
sizeof(*shdr4extnum)))
goto end_coredump; goto end_coredump;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment