switch elf_core_write_extra_data() to dump_emit()
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 5 Oct 2013 21:50:15 +0000 (17:50 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sat, 9 Nov 2013 05:16:23 +0000 (00:16 -0500)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
arch/ia64/kernel/elfcore.c
arch/x86/um/elfcore.c
fs/binfmt_elf.c
fs/binfmt_elf_fdpic.c
include/linux/elfcore.h

index 798ce543da4b1bdf644ebe406c3a2df9b8d8b3c3..04bc8fd5f893ed3dacd7ff487257277c193de571 100644 (file)
@@ -40,8 +40,7 @@ int elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset)
        return 1;
 }
 
-int elf_core_write_extra_data(struct file *file, size_t *size,
-                             unsigned long limit)
+int elf_core_write_extra_data(struct coredump_params *cprm)
 {
        const struct elf_phdr *const gate_phdrs =
                (const struct elf_phdr *) (GATE_ADDR + GATE_EHDR->e_phoff);
@@ -52,8 +51,7 @@ int elf_core_write_extra_data(struct file *file, size_t *size,
                        void *addr = (void *)gate_phdrs[i].p_vaddr;
                        size_t memsz = PAGE_ALIGN(gate_phdrs[i].p_memsz);
 
-                       *size += memsz;
-                       if (*size > limit || !dump_write(file, addr, memsz))
+                       if (!dump_emit(cprm, addr, memsz))
                                return 0;
                        break;
                }
index fc21f98efafe159b2e842cc20cbd589b0f45951c..7bb89a27a5e43c266583d753e0e270aa73a0ceda 100644 (file)
@@ -38,8 +38,7 @@ int elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset)
        return 1;
 }
 
-int elf_core_write_extra_data(struct file *file, size_t *size,
-                             unsigned long limit)
+int elf_core_write_extra_data(struct coredump_params *cprm)
 {
        if ( vsyscall_ehdr ) {
                const struct elfhdr *const ehdrp =
@@ -52,10 +51,7 @@ int elf_core_write_extra_data(struct file *file, size_t *size,
                        if (phdrp[i].p_type == PT_LOAD) {
                                void *addr = (void *) phdrp[i].p_vaddr;
                                size_t filesz = phdrp[i].p_filesz;
-
-                               *size += filesz;
-                               if (*size > limit
-                                   || !dump_write(file, addr, filesz))
+                               if (!dump_emit(cprm, addr, filesz))
                                        return 0;
                        }
                }
index 35c4886dae2d60ddcf182cbc068eee1277859540..a998b221b53a8a8fea43054a2871f1388702fa09 100644 (file)
@@ -2196,8 +2196,10 @@ static int elf_core_dump(struct coredump_params *cprm)
                }
        }
 
-       if (!elf_core_write_extra_data(cprm->file, &size, cprm->limit))
+       cprm->written = size;
+       if (!elf_core_write_extra_data(cprm))
                goto end_coredump;
+       size = cprm->written;
 
        if (e_phnum == PN_XNUM) {
                size += sizeof(*shdr4extnum);
index 44db8b92121a0d7f00078b93999bbcbe517ac026..77bf7e33e70636ee699f37abdedb777f9f01a04d 100644 (file)
@@ -1818,8 +1818,10 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
                                    cprm->mm_flags) < 0)
                goto end_coredump;
 
-       if (!elf_core_write_extra_data(cprm->file, &size, cprm->limit))
+       cprm->written = size;
+       if (!elf_core_write_extra_data(cprm))
                goto end_coredump;
+       size = cprm->written;
 
        if (e_phnum == PN_XNUM) {
                size += sizeof(*shdr4extnum);
index 1b92a8c406242d5988c0092995aab20971aa2bae..698d51a0eea3f3892f0912996f9ca50bd54d8d78 100644 (file)
@@ -67,7 +67,7 @@ extern Elf_Half elf_core_extra_phdrs(void);
 extern int
 elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset);
 extern int
-elf_core_write_extra_data(struct file *file, size_t *size, unsigned long limit);
+elf_core_write_extra_data(struct coredump_params *cprm);
 extern size_t elf_core_extra_data_size(void);
 
 #endif /* _LINUX_ELFCORE_H */