Skip to content

Commit

Permalink
coredump: let dump_emit() bail out on short writes
Browse files Browse the repository at this point in the history
dump_emit() has a retry loop, but there seems to be no way for that retry
logic to actually be used; and it was also buggy, writing the same data
repeatedly after a short write.

Let's just bail out on a short write.

Suggested-by: Linus Torvalds <[email protected]>
Signed-off-by: Jann Horn <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Acked-by: Linus Torvalds <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Alexander Viro <[email protected]>
Cc: "Eric W . Biederman" <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Cc: Hugh Dickins <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
thejh authored and torvalds committed Oct 16, 2020
1 parent 8f942ee commit df0c09c
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions fs/coredump.c
Original file line number Diff line number Diff line change
Expand Up @@ -840,17 +840,17 @@ int dump_emit(struct coredump_params *cprm, const void *addr, int nr)
ssize_t n;
if (cprm->written + nr > cprm->limit)
return 0;
while (nr) {
if (dump_interrupted())
return 0;
n = __kernel_write(file, addr, nr, &pos);
if (n <= 0)
return 0;
file->f_pos = pos;
cprm->written += n;
cprm->pos += n;
nr -= n;
}


if (dump_interrupted())
return 0;
n = __kernel_write(file, addr, nr, &pos);
if (n != nr)
return 0;
file->f_pos = pos;
cprm->written += n;
cprm->pos += n;

return 1;
}
EXPORT_SYMBOL(dump_emit);
Expand Down

0 comments on commit df0c09c

Please sign in to comment.