diff options
author | Omar Sandoval <osandov@fb.com> | 2016-05-11 18:16:36 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2016-05-12 16:55:50 -0400 |
commit | a00839395103d5e2d132a6c4a9680256580ed3d1 (patch) | |
tree | f45b3fdcdfcf65d722d3cf083527f876ebd1ea0d | |
parent | 88ae4ab9802eaa8e400e611f85883143d89d6b61 (diff) |
coredump: get rid of coredump_params->written
cprm->written is redundant with cprm->file->f_pos, so use that instead.
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | arch/powerpc/platforms/cell/spufs/coredump.c | 5 | ||||
-rw-r--r-- | fs/binfmt_elf.c | 2 | ||||
-rw-r--r-- | fs/binfmt_elf_fdpic.c | 2 | ||||
-rw-r--r-- | fs/coredump.c | 8 | ||||
-rw-r--r-- | include/linux/binfmts.h | 1 |
5 files changed, 8 insertions, 10 deletions
diff --git a/arch/powerpc/platforms/cell/spufs/coredump.c b/arch/powerpc/platforms/cell/spufs/coredump.c index be6212ddbf06..84fb984f29c1 100644 --- a/arch/powerpc/platforms/cell/spufs/coredump.c +++ b/arch/powerpc/platforms/cell/spufs/coredump.c | |||
@@ -137,6 +137,7 @@ static int spufs_arch_write_note(struct spu_context *ctx, int i, | |||
137 | char *name; | 137 | char *name; |
138 | char fullname[80], *buf; | 138 | char fullname[80], *buf; |
139 | struct elf_note en; | 139 | struct elf_note en; |
140 | size_t skip; | ||
140 | 141 | ||
141 | buf = (void *)get_zeroed_page(GFP_KERNEL); | 142 | buf = (void *)get_zeroed_page(GFP_KERNEL); |
142 | if (!buf) | 143 | if (!buf) |
@@ -171,8 +172,8 @@ static int spufs_arch_write_note(struct spu_context *ctx, int i, | |||
171 | if (rc < 0) | 172 | if (rc < 0) |
172 | goto out; | 173 | goto out; |
173 | 174 | ||
174 | if (!dump_skip(cprm, | 175 | skip = roundup(cprm->file->f_pos - total + sz, 4) - cprm->file->f_pos; |
175 | roundup(cprm->written - total + sz, 4) - cprm->written)) | 176 | if (!dump_skip(cprm, skip)) |
176 | goto Eio; | 177 | goto Eio; |
177 | out: | 178 | out: |
178 | free_page((unsigned long)buf); | 179 | free_page((unsigned long)buf); |
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 7d914c67a9d0..f5ce8f4e00b0 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
@@ -2273,7 +2273,7 @@ static int elf_core_dump(struct coredump_params *cprm) | |||
2273 | goto end_coredump; | 2273 | goto end_coredump; |
2274 | 2274 | ||
2275 | /* Align to page */ | 2275 | /* Align to page */ |
2276 | if (!dump_skip(cprm, dataoff - cprm->written)) | 2276 | if (!dump_skip(cprm, dataoff - cprm->file->f_pos)) |
2277 | goto end_coredump; | 2277 | goto end_coredump; |
2278 | 2278 | ||
2279 | for (i = 0, vma = first_vma(current, gate_vma); vma != NULL; | 2279 | for (i = 0, vma = first_vma(current, gate_vma); vma != NULL; |
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c index b1adb92e69de..8cfde2482468 100644 --- a/fs/binfmt_elf_fdpic.c +++ b/fs/binfmt_elf_fdpic.c | |||
@@ -1787,7 +1787,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm) | |||
1787 | goto end_coredump; | 1787 | goto end_coredump; |
1788 | } | 1788 | } |
1789 | 1789 | ||
1790 | if (!dump_skip(cprm, dataoff - cprm->written)) | 1790 | if (!dump_skip(cprm, dataoff - cprm->file->f_pos)) |
1791 | goto end_coredump; | 1791 | goto end_coredump; |
1792 | 1792 | ||
1793 | if (!elf_fdpic_dump_segments(cprm)) | 1793 | if (!elf_fdpic_dump_segments(cprm)) |
diff --git a/fs/coredump.c b/fs/coredump.c index 47c32c3bfa1d..9db0c514438e 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) | |||
782 | struct file *file = cprm->file; | 782 | struct file *file = cprm->file; |
783 | loff_t pos = file->f_pos; | 783 | loff_t pos = file->f_pos; |
784 | ssize_t n; | 784 | ssize_t n; |
785 | if (cprm->written + nr > cprm->limit) | 785 | if (pos + nr > cprm->limit) |
786 | return 0; | 786 | return 0; |
787 | while (nr) { | 787 | while (nr) { |
788 | if (dump_interrupted()) | 788 | if (dump_interrupted()) |
@@ -791,7 +791,6 @@ int dump_emit(struct coredump_params *cprm, const void *addr, int nr) | |||
791 | if (n <= 0) | 791 | if (n <= 0) |
792 | return 0; | 792 | return 0; |
793 | file->f_pos = pos; | 793 | file->f_pos = pos; |
794 | cprm->written += n; | ||
795 | nr -= n; | 794 | nr -= n; |
796 | } | 795 | } |
797 | return 1; | 796 | return 1; |
@@ -803,12 +802,11 @@ int dump_skip(struct coredump_params *cprm, size_t nr) | |||
803 | static char zeroes[PAGE_SIZE]; | 802 | static char zeroes[PAGE_SIZE]; |
804 | struct file *file = cprm->file; | 803 | struct file *file = cprm->file; |
805 | if (file->f_op->llseek && file->f_op->llseek != no_llseek) { | 804 | if (file->f_op->llseek && file->f_op->llseek != no_llseek) { |
806 | if (cprm->written + nr > cprm->limit) | 805 | if (file->f_pos + nr > cprm->limit) |
807 | return 0; | 806 | return 0; |
808 | if (dump_interrupted() || | 807 | if (dump_interrupted() || |
809 | file->f_op->llseek(file, nr, SEEK_CUR) < 0) | 808 | file->f_op->llseek(file, nr, SEEK_CUR) < 0) |
810 | return 0; | 809 | return 0; |
811 | cprm->written += nr; | ||
812 | return 1; | 810 | return 1; |
813 | } else { | 811 | } else { |
814 | while (nr > PAGE_SIZE) { | 812 | while (nr > PAGE_SIZE) { |
@@ -823,7 +821,7 @@ EXPORT_SYMBOL(dump_skip); | |||
823 | 821 | ||
824 | int dump_align(struct coredump_params *cprm, int align) | 822 | int dump_align(struct coredump_params *cprm, int align) |
825 | { | 823 | { |
826 | unsigned mod = cprm->written & (align - 1); | 824 | unsigned mod = cprm->file->f_pos & (align - 1); |
827 | if (align & (align - 1)) | 825 | if (align & (align - 1)) |
828 | return 0; | 826 | return 0; |
829 | return mod ? dump_skip(cprm, align - mod) : 1; | 827 | return mod ? dump_skip(cprm, align - mod) : 1; |
diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h index 576e4639ca60..39c6d6e1234e 100644 --- a/include/linux/binfmts.h +++ b/include/linux/binfmts.h | |||
@@ -64,7 +64,6 @@ struct coredump_params { | |||
64 | struct file *file; | 64 | struct file *file; |
65 | unsigned long limit; | 65 | unsigned long limit; |
66 | unsigned long mm_flags; | 66 | unsigned long mm_flags; |
67 | loff_t written; | ||
68 | }; | 67 | }; |
69 | 68 | ||
70 | /* | 69 | /* |