diff --git a/fs/coredump.c b/fs/coredump.c index 9db0c514438e38494e2ea78511f3645e84485535..492c2db25dc9bd654a3fb6931dc3bdc1162ac42d 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; diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h index 39c6d6e1234e5398846a8d77feac9e111cf3e925..576e4639ca609e8bfb8686474406073937e912e9 100644 --- a/include/linux/binfmts.h +++ b/include/linux/binfmts.h @@ -64,6 +64,7 @@ struct coredump_params { struct file *file; unsigned long limit; unsigned long mm_flags; + loff_t written; }; /*