diff options
| author | Christian Brauner <[email protected]> | 2025-05-16 11:25:30 +0000 |
|---|---|---|
| committer | Christian Brauner <[email protected]> | 2025-05-16 16:21:24 +0000 |
| commit | 1c587ee610b05e28a46584a7bae8c9db1510c90b (patch) | |
| tree | 8d5ff274b05204a8689ce25d444be6c8d5504b25 | |
| parent | coredump: massage do_coredump() (diff) | |
| download | kernel-1c587ee610b05e28a46584a7bae8c9db1510c90b.tar.gz kernel-1c587ee610b05e28a46584a7bae8c9db1510c90b.zip | |
coredump: reflow dump helpers a little
They look rather messy right now.
Link: https://lore.kernel.org/[email protected]
Acked-by: Luca Boccassi <[email protected]>
Reviewed-by: Jann Horn <[email protected]>
Reviewed-by: Alexander Mikhalitsyn <[email protected]>
Signed-off-by: Christian Brauner <[email protected]>
| -rw-r--r-- | fs/coredump.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/fs/coredump.c b/fs/coredump.c index 47c811d32028..4b9ea455a59c 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -864,10 +864,9 @@ static 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 (cprm->written + nr > cprm->limit) return 0; - - if (dump_interrupted()) return 0; n = __kernel_write(file, addr, nr, &pos); @@ -884,20 +883,21 @@ static int __dump_skip(struct coredump_params *cprm, size_t nr) { static char zeroes[PAGE_SIZE]; struct file *file = cprm->file; + if (file->f_mode & FMODE_LSEEK) { - if (dump_interrupted() || - vfs_llseek(file, nr, SEEK_CUR) < 0) + if (dump_interrupted() || vfs_llseek(file, nr, SEEK_CUR) < 0) return 0; cprm->pos += nr; return 1; - } else { - while (nr > PAGE_SIZE) { - if (!__dump_emit(cprm, zeroes, PAGE_SIZE)) - return 0; - nr -= PAGE_SIZE; - } - return __dump_emit(cprm, zeroes, nr); } + + while (nr > PAGE_SIZE) { + if (!__dump_emit(cprm, zeroes, PAGE_SIZE)) + return 0; + nr -= PAGE_SIZE; + } + + return __dump_emit(cprm, zeroes, nr); } int dump_emit(struct coredump_params *cprm, const void *addr, int nr) |
