make dump_emit() use vfs_write() instead of banging at ->f_op->write directly
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 8 Oct 2013 13:11:48 +0000 (09:11 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sat, 9 Nov 2013 05:16:26 +0000 (00:16 -0500)
... and deal with short writes properly - the output might be to pipe, after
all; as it is, e.g. no-MMU case of elf_fdpic coredump can write a whole lot
more than a page worth of data at one call.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/coredump.c

index 319f973bab729cc875ede0f7fa217434e0512e78..2472ed9e682c94128667ffee6aaca6b0ae5e5d50 100644 (file)
@@ -696,13 +696,20 @@ EXPORT_SYMBOL(dump_write);
 int dump_emit(struct coredump_params *cprm, const void *addr, int nr)
 {
        struct file *file = cprm->file;
-       if (dump_interrupted() || !access_ok(VERIFY_READ, addr, nr))
-               return 0;
+       loff_t pos = file->f_pos;
+       ssize_t n;
        if (cprm->written + nr > cprm->limit)
                return 0;
-       if (file->f_op->write(file, addr, nr, &file->f_pos) != nr)
-               return 0;
-       cprm->written += nr;
+       while (nr) {
+               if (dump_interrupted())
+                       return 0;
+               n = vfs_write(file, addr, nr, &pos);
+               if (n <= 0)
+                       return 0;
+               file->f_pos = pos;
+               cprm->written += n;
+               nr -= n;
+       }
        return 1;
 }
 EXPORT_SYMBOL(dump_emit);