Skip to content

Commit 2507a4f

Browse files
author
Al Viro
committed
make dump_emit() use vfs_write() instead of banging at ->f_op->write directly
... 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>
1 parent 1ad6701 commit 2507a4f

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

‎fs/coredump.c‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -696,13 +696,20 @@ EXPORT_SYMBOL(dump_write);
696696
int dump_emit(struct coredump_params *cprm, const void *addr, int nr)
697697
{
698698
struct file *file = cprm->file;
699-
if (dump_interrupted() || !access_ok(VERIFY_READ, addr, nr))
700-
return 0;
699+
loff_t pos = file->f_pos;
700+
ssize_t n;
701701
if (cprm->written + nr > cprm->limit)
702702
return 0;
703-
if (file->f_op->write(file, addr, nr, &file->f_pos) != nr)
704-
return 0;
705-
cprm->written += nr;
703+
while (nr) {
704+
if (dump_interrupted())
705+
return 0;
706+
n = vfs_write(file, addr, nr, &pos);
707+
if (n <= 0)
708+
return 0;
709+
file->f_pos = pos;
710+
cprm->written += n;
711+
nr -= n;
712+
}
706713
return 1;
707714
}
708715
EXPORT_SYMBOL(dump_emit);

0 commit comments

Comments
 (0)