Commit df0c09c0 authored by Jann Horn's avatar Jann Horn Committed by Linus Torvalds

coredump: let dump_emit() bail out on short writes

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: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarJann Horn <jannh@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Acked-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: "Eric W . Biederman" <ebiederm@xmission.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Link: http://lkml.kernel.org/r/20200827114932.3572699-3-jannh@google.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 8f942eea
...@@ -840,17 +840,17 @@ int dump_emit(struct coredump_params *cprm, const void *addr, int nr) ...@@ -840,17 +840,17 @@ int dump_emit(struct coredump_params *cprm, const void *addr, int nr)
ssize_t n; ssize_t n;
if (cprm->written + nr > cprm->limit) if (cprm->written + nr > cprm->limit)
return 0; return 0;
while (nr) {
if (dump_interrupted())
return 0; if (dump_interrupted())
n = __kernel_write(file, addr, nr, &pos); return 0;
if (n <= 0) n = __kernel_write(file, addr, nr, &pos);
return 0; if (n != nr)
file->f_pos = pos; return 0;
cprm->written += n; file->f_pos = pos;
cprm->pos += n; cprm->written += n;
nr -= n; cprm->pos += n;
}
return 1; return 1;
} }
EXPORT_SYMBOL(dump_emit); EXPORT_SYMBOL(dump_emit);
......
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