diff options
author | Omar Sandoval <osandov@fb.com> | 2016-05-12 00:16:37 +0200 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2016-05-12 22:55:50 +0200 |
commit | 2c4cb04300fa160e9d78335c74184c4e66a56437 (patch) | |
tree | ff36e8066fe5092e23cc2519adfd976eb54bc0b8 /fs/coredump.c | |
parent | coredump: get rid of coredump_params->written (diff) | |
download | linux-2c4cb04300fa160e9d78335c74184c4e66a56437.tar.xz linux-2c4cb04300fa160e9d78335c74184c4e66a56437.zip |
coredump: only charge written data against RLIMIT_CORE
Commit 9b56d54380ad ("dump_skip(): dump_seek() replacement taking
coredump_params") introduced a regression with regard to RLIMIT_CORE.
Previously, when a core dump was sparse, only the data that was actually
written out would count against the limit. Now, the sparse ranges are
also included, which leads to truncated core dumps when the actual disk
usage is still well below the limit. Restore the old behavior by only
counting what gets emitted and ignoring what gets skipped.
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/coredump.c')
-rw-r--r-- | fs/coredump.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/fs/coredump.c b/fs/coredump.c index 9db0c514438e..492c2db25dc9 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -782,7 +782,7 @@ int dump_emit(struct coredump_params *cprm, const void *addr, int nr) struct file *file = cprm->file; loff_t pos = file->f_pos; ssize_t n; - if (pos + nr > cprm->limit) + if (cprm->written + nr > cprm->limit) return 0; while (nr) { if (dump_interrupted()) @@ -791,6 +791,7 @@ int dump_emit(struct coredump_params *cprm, const void *addr, int nr) if (n <= 0) return 0; file->f_pos = pos; + cprm->written += n; nr -= n; } return 1; @@ -802,8 +803,6 @@ int dump_skip(struct coredump_params *cprm, size_t nr) static char zeroes[PAGE_SIZE]; struct file *file = cprm->file; if (file->f_op->llseek && file->f_op->llseek != no_llseek) { - if (file->f_pos + nr > cprm->limit) - return 0; if (dump_interrupted() || file->f_op->llseek(file, nr, SEEK_CUR) < 0) return 0; |