diff options
-rw-r--r-- | arch/mips/kernel/elf.c | 12 | ||||
-rw-r--r-- | arch/x86/ia32/ia32_aout.c | 4 | ||||
-rw-r--r-- | drivers/media/pci/cx25821/cx25821-audio-upstream.c | 13 | ||||
-rw-r--r-- | drivers/mtd/nand/nandsim.c | 2 | ||||
-rw-r--r-- | fs/binfmt_aout.c | 3 | ||||
-rw-r--r-- | fs/binfmt_elf.c | 23 | ||||
-rw-r--r-- | fs/binfmt_elf_fdpic.c | 17 | ||||
-rw-r--r-- | fs/binfmt_flat.c | 18 | ||||
-rw-r--r-- | fs/binfmt_misc.c | 5 | ||||
-rw-r--r-- | fs/coda/dir.c | 5 | ||||
-rw-r--r-- | fs/ecryptfs/read_write.c | 2 | ||||
-rw-r--r-- | fs/exec.c | 7 | ||||
-rw-r--r-- | fs/read_write.c | 8 | ||||
-rw-r--r-- | include/linux/fs.h | 2 | ||||
-rw-r--r-- | kernel/sysctl_binary.c | 12 | ||||
-rw-r--r-- | net/9p/trans_fd.c | 4 | ||||
-rw-r--r-- | security/keys/big_key.c | 3 |
17 files changed, 69 insertions, 71 deletions
diff --git a/arch/mips/kernel/elf.c b/arch/mips/kernel/elf.c index 5c429d70e17f..0828d6d963b7 100644 --- a/arch/mips/kernel/elf.c +++ b/arch/mips/kernel/elf.c | |||
@@ -87,6 +87,7 @@ int arch_elf_pt_proc(void *_ehdr, void *_phdr, struct file *elf, | |||
87 | bool elf32; | 87 | bool elf32; |
88 | u32 flags; | 88 | u32 flags; |
89 | int ret; | 89 | int ret; |
90 | loff_t pos; | ||
90 | 91 | ||
91 | elf32 = ehdr->e32.e_ident[EI_CLASS] == ELFCLASS32; | 92 | elf32 = ehdr->e32.e_ident[EI_CLASS] == ELFCLASS32; |
92 | flags = elf32 ? ehdr->e32.e_flags : ehdr->e64.e_flags; | 93 | flags = elf32 ? ehdr->e32.e_flags : ehdr->e64.e_flags; |
@@ -108,21 +109,16 @@ int arch_elf_pt_proc(void *_ehdr, void *_phdr, struct file *elf, | |||
108 | 109 | ||
109 | if (phdr32->p_filesz < sizeof(abiflags)) | 110 | if (phdr32->p_filesz < sizeof(abiflags)) |
110 | return -EINVAL; | 111 | return -EINVAL; |
111 | 112 | pos = phdr32->p_offset; | |
112 | ret = kernel_read(elf, phdr32->p_offset, | ||
113 | (char *)&abiflags, | ||
114 | sizeof(abiflags)); | ||
115 | } else { | 113 | } else { |
116 | if (phdr64->p_type != PT_MIPS_ABIFLAGS) | 114 | if (phdr64->p_type != PT_MIPS_ABIFLAGS) |
117 | return 0; | 115 | return 0; |
118 | if (phdr64->p_filesz < sizeof(abiflags)) | 116 | if (phdr64->p_filesz < sizeof(abiflags)) |
119 | return -EINVAL; | 117 | return -EINVAL; |
120 | 118 | pos = phdr64->p_offset; | |
121 | ret = kernel_read(elf, phdr64->p_offset, | ||
122 | (char *)&abiflags, | ||
123 | sizeof(abiflags)); | ||
124 | } | 119 | } |
125 | 120 | ||
121 | ret = kernel_read(elf, &abiflags, sizeof(abiflags), &pos); | ||
126 | if (ret < 0) | 122 | if (ret < 0) |
127 | return ret; | 123 | return ret; |
128 | if (ret != sizeof(abiflags)) | 124 | if (ret != sizeof(abiflags)) |
diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c index 8d0879f1d42c..8e02b30cf08e 100644 --- a/arch/x86/ia32/ia32_aout.c +++ b/arch/x86/ia32/ia32_aout.c | |||
@@ -407,10 +407,10 @@ static int load_aout_library(struct file *file) | |||
407 | unsigned long bss, start_addr, len, error; | 407 | unsigned long bss, start_addr, len, error; |
408 | int retval; | 408 | int retval; |
409 | struct exec ex; | 409 | struct exec ex; |
410 | 410 | loff_t pos = 0; | |
411 | 411 | ||
412 | retval = -ENOEXEC; | 412 | retval = -ENOEXEC; |
413 | error = kernel_read(file, 0, (char *) &ex, sizeof(ex)); | 413 | error = kernel_read(file, &ex, sizeof(ex), &pos); |
414 | if (error != sizeof(ex)) | 414 | if (error != sizeof(ex)) |
415 | goto out; | 415 | goto out; |
416 | 416 | ||
diff --git a/drivers/media/pci/cx25821/cx25821-audio-upstream.c b/drivers/media/pci/cx25821/cx25821-audio-upstream.c index b94eb1c0023d..ada26d4acfb4 100644 --- a/drivers/media/pci/cx25821/cx25821-audio-upstream.c +++ b/drivers/media/pci/cx25821/cx25821-audio-upstream.c | |||
@@ -277,7 +277,7 @@ static int cx25821_get_audio_data(struct cx25821_dev *dev, | |||
277 | p = (char *)dev->_audiodata_buf_virt_addr + frame_offset; | 277 | p = (char *)dev->_audiodata_buf_virt_addr + frame_offset; |
278 | 278 | ||
279 | for (i = 0; i < dev->_audio_lines_count; i++) { | 279 | for (i = 0; i < dev->_audio_lines_count; i++) { |
280 | int n = kernel_read(file, file_offset, mybuf, AUDIO_LINE_SIZE); | 280 | int n = kernel_read(file, mybuf, AUDIO_LINE_SIZE, &file_offset); |
281 | if (n < AUDIO_LINE_SIZE) { | 281 | if (n < AUDIO_LINE_SIZE) { |
282 | pr_info("Done: exit %s() since no more bytes to read from Audio file\n", | 282 | pr_info("Done: exit %s() since no more bytes to read from Audio file\n", |
283 | __func__); | 283 | __func__); |
@@ -290,7 +290,6 @@ static int cx25821_get_audio_data(struct cx25821_dev *dev, | |||
290 | memcpy(p, mybuf, n); | 290 | memcpy(p, mybuf, n); |
291 | p += n; | 291 | p += n; |
292 | } | 292 | } |
293 | file_offset += n; | ||
294 | } | 293 | } |
295 | dev->_audioframe_count++; | 294 | dev->_audioframe_count++; |
296 | fput(file); | 295 | fput(file); |
@@ -318,7 +317,7 @@ static int cx25821_openfile_audio(struct cx25821_dev *dev, | |||
318 | { | 317 | { |
319 | char *p = (void *)dev->_audiodata_buf_virt_addr; | 318 | char *p = (void *)dev->_audiodata_buf_virt_addr; |
320 | struct file *file; | 319 | struct file *file; |
321 | loff_t offset; | 320 | loff_t file_offset = 0; |
322 | int i, j; | 321 | int i, j; |
323 | 322 | ||
324 | file = filp_open(dev->_audiofilename, O_RDONLY | O_LARGEFILE, 0); | 323 | file = filp_open(dev->_audiofilename, O_RDONLY | O_LARGEFILE, 0); |
@@ -328,11 +327,11 @@ static int cx25821_openfile_audio(struct cx25821_dev *dev, | |||
328 | return PTR_ERR(file); | 327 | return PTR_ERR(file); |
329 | } | 328 | } |
330 | 329 | ||
331 | for (j = 0, offset = 0; j < NUM_AUDIO_FRAMES; j++) { | 330 | for (j = 0; j < NUM_AUDIO_FRAMES; j++) { |
332 | for (i = 0; i < dev->_audio_lines_count; i++) { | 331 | for (i = 0; i < dev->_audio_lines_count; i++) { |
333 | char buf[AUDIO_LINE_SIZE]; | 332 | char buf[AUDIO_LINE_SIZE]; |
334 | int n = kernel_read(file, offset, buf, | 333 | loff_t offset = file_offset; |
335 | AUDIO_LINE_SIZE); | 334 | int n = kernel_read(file, buf, AUDIO_LINE_SIZE, &file_offset); |
336 | 335 | ||
337 | if (n < AUDIO_LINE_SIZE) { | 336 | if (n < AUDIO_LINE_SIZE) { |
338 | pr_info("Done: exit %s() since no more bytes to read from Audio file\n", | 337 | pr_info("Done: exit %s() since no more bytes to read from Audio file\n", |
@@ -344,8 +343,6 @@ static int cx25821_openfile_audio(struct cx25821_dev *dev, | |||
344 | 343 | ||
345 | if (p) | 344 | if (p) |
346 | memcpy(p + offset, buf, n); | 345 | memcpy(p + offset, buf, n); |
347 | |||
348 | offset += n; | ||
349 | } | 346 | } |
350 | dev->_audioframe_count++; | 347 | dev->_audioframe_count++; |
351 | } | 348 | } |
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c index e4211c3cc49b..a8089656879a 100644 --- a/drivers/mtd/nand/nandsim.c +++ b/drivers/mtd/nand/nandsim.c | |||
@@ -1379,7 +1379,7 @@ static ssize_t read_file(struct nandsim *ns, struct file *file, void *buf, size_ | |||
1379 | if (err) | 1379 | if (err) |
1380 | return err; | 1380 | return err; |
1381 | noreclaim_flag = memalloc_noreclaim_save(); | 1381 | noreclaim_flag = memalloc_noreclaim_save(); |
1382 | tx = kernel_read(file, pos, buf, count); | 1382 | tx = kernel_read(file, buf, count, &pos); |
1383 | memalloc_noreclaim_restore(noreclaim_flag); | 1383 | memalloc_noreclaim_restore(noreclaim_flag); |
1384 | put_pages(ns); | 1384 | put_pages(ns); |
1385 | return tx; | 1385 | return tx; |
diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c index 9be82c4e14a4..ce1824f47ba6 100644 --- a/fs/binfmt_aout.c +++ b/fs/binfmt_aout.c | |||
@@ -341,11 +341,12 @@ static int load_aout_library(struct file *file) | |||
341 | unsigned long error; | 341 | unsigned long error; |
342 | int retval; | 342 | int retval; |
343 | struct exec ex; | 343 | struct exec ex; |
344 | loff_t pos = 0; | ||
344 | 345 | ||
345 | inode = file_inode(file); | 346 | inode = file_inode(file); |
346 | 347 | ||
347 | retval = -ENOEXEC; | 348 | retval = -ENOEXEC; |
348 | error = kernel_read(file, 0, (char *) &ex, sizeof(ex)); | 349 | error = kernel_read(file, &ex, sizeof(ex), &pos); |
349 | if (error != sizeof(ex)) | 350 | if (error != sizeof(ex)) |
350 | goto out; | 351 | goto out; |
351 | 352 | ||
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 6466153f2bf0..2f928b87c90e 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
@@ -409,6 +409,7 @@ static struct elf_phdr *load_elf_phdrs(struct elfhdr *elf_ex, | |||
409 | { | 409 | { |
410 | struct elf_phdr *elf_phdata = NULL; | 410 | struct elf_phdr *elf_phdata = NULL; |
411 | int retval, size, err = -1; | 411 | int retval, size, err = -1; |
412 | loff_t pos = elf_ex->e_phoff; | ||
412 | 413 | ||
413 | /* | 414 | /* |
414 | * If the size of this structure has changed, then punt, since | 415 | * If the size of this structure has changed, then punt, since |
@@ -432,8 +433,7 @@ static struct elf_phdr *load_elf_phdrs(struct elfhdr *elf_ex, | |||
432 | goto out; | 433 | goto out; |
433 | 434 | ||
434 | /* Read in the program headers */ | 435 | /* Read in the program headers */ |
435 | retval = kernel_read(elf_file, elf_ex->e_phoff, | 436 | retval = kernel_read(elf_file, elf_phdata, size, &pos); |
436 | (char *)elf_phdata, size); | ||
437 | if (retval != size) { | 437 | if (retval != size) { |
438 | err = (retval < 0) ? retval : -EIO; | 438 | err = (retval < 0) ? retval : -EIO; |
439 | goto out; | 439 | goto out; |
@@ -698,6 +698,7 @@ static int load_elf_binary(struct linux_binprm *bprm) | |||
698 | struct elfhdr interp_elf_ex; | 698 | struct elfhdr interp_elf_ex; |
699 | } *loc; | 699 | } *loc; |
700 | struct arch_elf_state arch_state = INIT_ARCH_ELF_STATE; | 700 | struct arch_elf_state arch_state = INIT_ARCH_ELF_STATE; |
701 | loff_t pos; | ||
701 | 702 | ||
702 | loc = kmalloc(sizeof(*loc), GFP_KERNEL); | 703 | loc = kmalloc(sizeof(*loc), GFP_KERNEL); |
703 | if (!loc) { | 704 | if (!loc) { |
@@ -750,9 +751,9 @@ static int load_elf_binary(struct linux_binprm *bprm) | |||
750 | if (!elf_interpreter) | 751 | if (!elf_interpreter) |
751 | goto out_free_ph; | 752 | goto out_free_ph; |
752 | 753 | ||
753 | retval = kernel_read(bprm->file, elf_ppnt->p_offset, | 754 | pos = elf_ppnt->p_offset; |
754 | elf_interpreter, | 755 | retval = kernel_read(bprm->file, elf_interpreter, |
755 | elf_ppnt->p_filesz); | 756 | elf_ppnt->p_filesz, &pos); |
756 | if (retval != elf_ppnt->p_filesz) { | 757 | if (retval != elf_ppnt->p_filesz) { |
757 | if (retval >= 0) | 758 | if (retval >= 0) |
758 | retval = -EIO; | 759 | retval = -EIO; |
@@ -776,9 +777,9 @@ static int load_elf_binary(struct linux_binprm *bprm) | |||
776 | would_dump(bprm, interpreter); | 777 | would_dump(bprm, interpreter); |
777 | 778 | ||
778 | /* Get the exec headers */ | 779 | /* Get the exec headers */ |
779 | retval = kernel_read(interpreter, 0, | 780 | pos = 0; |
780 | (void *)&loc->interp_elf_ex, | 781 | retval = kernel_read(interpreter, &loc->interp_elf_ex, |
781 | sizeof(loc->interp_elf_ex)); | 782 | sizeof(loc->interp_elf_ex), &pos); |
782 | if (retval != sizeof(loc->interp_elf_ex)) { | 783 | if (retval != sizeof(loc->interp_elf_ex)) { |
783 | if (retval >= 0) | 784 | if (retval >= 0) |
784 | retval = -EIO; | 785 | retval = -EIO; |
@@ -1175,9 +1176,10 @@ static int load_elf_library(struct file *file) | |||
1175 | unsigned long elf_bss, bss, len; | 1176 | unsigned long elf_bss, bss, len; |
1176 | int retval, error, i, j; | 1177 | int retval, error, i, j; |
1177 | struct elfhdr elf_ex; | 1178 | struct elfhdr elf_ex; |
1179 | loff_t pos = 0; | ||
1178 | 1180 | ||
1179 | error = -ENOEXEC; | 1181 | error = -ENOEXEC; |
1180 | retval = kernel_read(file, 0, (char *)&elf_ex, sizeof(elf_ex)); | 1182 | retval = kernel_read(file, &elf_ex, sizeof(elf_ex), &pos); |
1181 | if (retval != sizeof(elf_ex)) | 1183 | if (retval != sizeof(elf_ex)) |
1182 | goto out; | 1184 | goto out; |
1183 | 1185 | ||
@@ -1201,7 +1203,8 @@ static int load_elf_library(struct file *file) | |||
1201 | 1203 | ||
1202 | eppnt = elf_phdata; | 1204 | eppnt = elf_phdata; |
1203 | error = -ENOEXEC; | 1205 | error = -ENOEXEC; |
1204 | retval = kernel_read(file, elf_ex.e_phoff, (char *)eppnt, j); | 1206 | pos = elf_ex.e_phoff; |
1207 | retval = kernel_read(file, eppnt, j, &pos); | ||
1205 | if (retval != j) | 1208 | if (retval != j) |
1206 | goto out_free_ph; | 1209 | goto out_free_ph; |
1207 | 1210 | ||
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c index cf93a4fad012..b4ebfe203a68 100644 --- a/fs/binfmt_elf_fdpic.c +++ b/fs/binfmt_elf_fdpic.c | |||
@@ -145,6 +145,7 @@ static int elf_fdpic_fetch_phdrs(struct elf_fdpic_params *params, | |||
145 | struct elf32_phdr *phdr; | 145 | struct elf32_phdr *phdr; |
146 | unsigned long size; | 146 | unsigned long size; |
147 | int retval, loop; | 147 | int retval, loop; |
148 | loff_t pos = params->hdr.e_phoff; | ||
148 | 149 | ||
149 | if (params->hdr.e_phentsize != sizeof(struct elf_phdr)) | 150 | if (params->hdr.e_phentsize != sizeof(struct elf_phdr)) |
150 | return -ENOMEM; | 151 | return -ENOMEM; |
@@ -156,8 +157,7 @@ static int elf_fdpic_fetch_phdrs(struct elf_fdpic_params *params, | |||
156 | if (!params->phdrs) | 157 | if (!params->phdrs) |
157 | return -ENOMEM; | 158 | return -ENOMEM; |
158 | 159 | ||
159 | retval = kernel_read(file, params->hdr.e_phoff, | 160 | retval = kernel_read(file, params->phdrs, size, &pos); |
160 | (char *) params->phdrs, size); | ||
161 | if (unlikely(retval != size)) | 161 | if (unlikely(retval != size)) |
162 | return retval < 0 ? retval : -ENOEXEC; | 162 | return retval < 0 ? retval : -ENOEXEC; |
163 | 163 | ||
@@ -199,6 +199,7 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm) | |||
199 | char *interpreter_name = NULL; | 199 | char *interpreter_name = NULL; |
200 | int executable_stack; | 200 | int executable_stack; |
201 | int retval, i; | 201 | int retval, i; |
202 | loff_t pos; | ||
202 | 203 | ||
203 | kdebug("____ LOAD %d ____", current->pid); | 204 | kdebug("____ LOAD %d ____", current->pid); |
204 | 205 | ||
@@ -246,10 +247,9 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm) | |||
246 | if (!interpreter_name) | 247 | if (!interpreter_name) |
247 | goto error; | 248 | goto error; |
248 | 249 | ||
249 | retval = kernel_read(bprm->file, | 250 | pos = phdr->p_offset; |
250 | phdr->p_offset, | 251 | retval = kernel_read(bprm->file, interpreter_name, |
251 | interpreter_name, | 252 | phdr->p_filesz, &pos); |
252 | phdr->p_filesz); | ||
253 | if (unlikely(retval != phdr->p_filesz)) { | 253 | if (unlikely(retval != phdr->p_filesz)) { |
254 | if (retval >= 0) | 254 | if (retval >= 0) |
255 | retval = -ENOEXEC; | 255 | retval = -ENOEXEC; |
@@ -277,8 +277,9 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm) | |||
277 | */ | 277 | */ |
278 | would_dump(bprm, interpreter); | 278 | would_dump(bprm, interpreter); |
279 | 279 | ||
280 | retval = kernel_read(interpreter, 0, bprm->buf, | 280 | pos = 0; |
281 | BINPRM_BUF_SIZE); | 281 | retval = kernel_read(interpreter, bprm->buf, |
282 | BINPRM_BUF_SIZE, &pos); | ||
282 | if (unlikely(retval != BINPRM_BUF_SIZE)) { | 283 | if (unlikely(retval != BINPRM_BUF_SIZE)) { |
283 | if (retval >= 0) | 284 | if (retval >= 0) |
284 | retval = -ENOEXEC; | 285 | retval = -ENOEXEC; |
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c index a1e6860b6f46..afb7e9d521d2 100644 --- a/fs/binfmt_flat.c +++ b/fs/binfmt_flat.c | |||
@@ -176,19 +176,14 @@ static int create_flat_tables(struct linux_binprm *bprm, unsigned long arg_start | |||
176 | #define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */ | 176 | #define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */ |
177 | #define RESERVED 0xC0 /* bit 6,7: reserved */ | 177 | #define RESERVED 0xC0 /* bit 6,7: reserved */ |
178 | 178 | ||
179 | static int decompress_exec( | 179 | static int decompress_exec(struct linux_binprm *bprm, loff_t fpos, char *dst, |
180 | struct linux_binprm *bprm, | 180 | long len, int fd) |
181 | unsigned long offset, | ||
182 | char *dst, | ||
183 | long len, | ||
184 | int fd) | ||
185 | { | 181 | { |
186 | unsigned char *buf; | 182 | unsigned char *buf; |
187 | z_stream strm; | 183 | z_stream strm; |
188 | loff_t fpos; | ||
189 | int ret, retval; | 184 | int ret, retval; |
190 | 185 | ||
191 | pr_debug("decompress_exec(offset=%lx,buf=%p,len=%lx)\n", offset, dst, len); | 186 | pr_debug("decompress_exec(offset=%llx,buf=%p,len=%lx)\n", fpos, dst, len); |
192 | 187 | ||
193 | memset(&strm, 0, sizeof(strm)); | 188 | memset(&strm, 0, sizeof(strm)); |
194 | strm.workspace = kmalloc(zlib_inflate_workspacesize(), GFP_KERNEL); | 189 | strm.workspace = kmalloc(zlib_inflate_workspacesize(), GFP_KERNEL); |
@@ -204,13 +199,11 @@ static int decompress_exec( | |||
204 | } | 199 | } |
205 | 200 | ||
206 | /* Read in first chunk of data and parse gzip header. */ | 201 | /* Read in first chunk of data and parse gzip header. */ |
207 | fpos = offset; | 202 | ret = kernel_read(bprm->file, buf, LBUFSIZE, &fpos); |
208 | ret = kernel_read(bprm->file, offset, buf, LBUFSIZE); | ||
209 | 203 | ||
210 | strm.next_in = buf; | 204 | strm.next_in = buf; |
211 | strm.avail_in = ret; | 205 | strm.avail_in = ret; |
212 | strm.total_in = 0; | 206 | strm.total_in = 0; |
213 | fpos += ret; | ||
214 | 207 | ||
215 | retval = -ENOEXEC; | 208 | retval = -ENOEXEC; |
216 | 209 | ||
@@ -276,7 +269,7 @@ static int decompress_exec( | |||
276 | } | 269 | } |
277 | 270 | ||
278 | while ((ret = zlib_inflate(&strm, Z_NO_FLUSH)) == Z_OK) { | 271 | while ((ret = zlib_inflate(&strm, Z_NO_FLUSH)) == Z_OK) { |
279 | ret = kernel_read(bprm->file, fpos, buf, LBUFSIZE); | 272 | ret = kernel_read(bprm->file, buf, LBUFSIZE, &fpos); |
280 | if (ret <= 0) | 273 | if (ret <= 0) |
281 | break; | 274 | break; |
282 | len -= ret; | 275 | len -= ret; |
@@ -284,7 +277,6 @@ static int decompress_exec( | |||
284 | strm.next_in = buf; | 277 | strm.next_in = buf; |
285 | strm.avail_in = ret; | 278 | strm.avail_in = ret; |
286 | strm.total_in = 0; | 279 | strm.total_in = 0; |
287 | fpos += ret; | ||
288 | } | 280 | } |
289 | 281 | ||
290 | if (ret < 0) { | 282 | if (ret < 0) { |
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c index f4718098ac31..ce7181ea60fa 100644 --- a/fs/binfmt_misc.c +++ b/fs/binfmt_misc.c | |||
@@ -218,12 +218,15 @@ static int load_misc_binary(struct linux_binprm *bprm) | |||
218 | 218 | ||
219 | bprm->file = interp_file; | 219 | bprm->file = interp_file; |
220 | if (fmt->flags & MISC_FMT_CREDENTIALS) { | 220 | if (fmt->flags & MISC_FMT_CREDENTIALS) { |
221 | loff_t pos = 0; | ||
222 | |||
221 | /* | 223 | /* |
222 | * No need to call prepare_binprm(), it's already been | 224 | * No need to call prepare_binprm(), it's already been |
223 | * done. bprm->buf is stale, update from interp_file. | 225 | * done. bprm->buf is stale, update from interp_file. |
224 | */ | 226 | */ |
225 | memset(bprm->buf, 0, BINPRM_BUF_SIZE); | 227 | memset(bprm->buf, 0, BINPRM_BUF_SIZE); |
226 | retval = kernel_read(bprm->file, 0, bprm->buf, BINPRM_BUF_SIZE); | 228 | retval = kernel_read(bprm->file, bprm->buf, BINPRM_BUF_SIZE, |
229 | &pos); | ||
227 | } else | 230 | } else |
228 | retval = prepare_binprm(bprm); | 231 | retval = prepare_binprm(bprm); |
229 | 232 | ||
diff --git a/fs/coda/dir.c b/fs/coda/dir.c index c0474ac6cbf2..274ab5586dd0 100644 --- a/fs/coda/dir.c +++ b/fs/coda/dir.c | |||
@@ -368,9 +368,10 @@ static int coda_venus_readdir(struct file *coda_file, struct dir_context *ctx) | |||
368 | goto out; | 368 | goto out; |
369 | 369 | ||
370 | while (1) { | 370 | while (1) { |
371 | loff_t pos = ctx->pos - 2; | ||
372 | |||
371 | /* read entries from the directory file */ | 373 | /* read entries from the directory file */ |
372 | ret = kernel_read(host_file, ctx->pos - 2, (char *)vdir, | 374 | ret = kernel_read(host_file, vdir, sizeof(*vdir), &pos); |
373 | sizeof(*vdir)); | ||
374 | if (ret < 0) { | 375 | if (ret < 0) { |
375 | pr_err("%s: read dir %s failed %d\n", | 376 | pr_err("%s: read dir %s failed %d\n", |
376 | __func__, coda_f2s(&cii->c_fid), ret); | 377 | __func__, coda_f2s(&cii->c_fid), ret); |
diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c index 039e627194a9..d8af0e99bfaf 100644 --- a/fs/ecryptfs/read_write.c +++ b/fs/ecryptfs/read_write.c | |||
@@ -237,7 +237,7 @@ int ecryptfs_read_lower(char *data, loff_t offset, size_t size, | |||
237 | lower_file = ecryptfs_inode_to_private(ecryptfs_inode)->lower_file; | 237 | lower_file = ecryptfs_inode_to_private(ecryptfs_inode)->lower_file; |
238 | if (!lower_file) | 238 | if (!lower_file) |
239 | return -EIO; | 239 | return -EIO; |
240 | return kernel_read(lower_file, offset, data, size); | 240 | return kernel_read(lower_file, data, size, &offset); |
241 | } | 241 | } |
242 | 242 | ||
243 | /** | 243 | /** |
@@ -922,8 +922,7 @@ int kernel_read_file(struct file *file, void **buf, loff_t *size, | |||
922 | 922 | ||
923 | pos = 0; | 923 | pos = 0; |
924 | while (pos < i_size) { | 924 | while (pos < i_size) { |
925 | bytes = kernel_read(file, pos, (char *)(*buf) + pos, | 925 | bytes = kernel_read(file, *buf + pos, i_size - pos, &pos); |
926 | i_size - pos); | ||
927 | if (bytes < 0) { | 926 | if (bytes < 0) { |
928 | ret = bytes; | 927 | ret = bytes; |
929 | goto out; | 928 | goto out; |
@@ -931,7 +930,6 @@ int kernel_read_file(struct file *file, void **buf, loff_t *size, | |||
931 | 930 | ||
932 | if (bytes == 0) | 931 | if (bytes == 0) |
933 | break; | 932 | break; |
934 | pos += bytes; | ||
935 | } | 933 | } |
936 | 934 | ||
937 | if (pos != i_size) { | 935 | if (pos != i_size) { |
@@ -1524,6 +1522,7 @@ static void bprm_fill_uid(struct linux_binprm *bprm) | |||
1524 | int prepare_binprm(struct linux_binprm *bprm) | 1522 | int prepare_binprm(struct linux_binprm *bprm) |
1525 | { | 1523 | { |
1526 | int retval; | 1524 | int retval; |
1525 | loff_t pos = 0; | ||
1527 | 1526 | ||
1528 | bprm_fill_uid(bprm); | 1527 | bprm_fill_uid(bprm); |
1529 | 1528 | ||
@@ -1534,7 +1533,7 @@ int prepare_binprm(struct linux_binprm *bprm) | |||
1534 | bprm->cred_prepared = 1; | 1533 | bprm->cred_prepared = 1; |
1535 | 1534 | ||
1536 | memset(bprm->buf, 0, BINPRM_BUF_SIZE); | 1535 | memset(bprm->buf, 0, BINPRM_BUF_SIZE); |
1537 | return kernel_read(bprm->file, 0, bprm->buf, BINPRM_BUF_SIZE); | 1536 | return kernel_read(bprm->file, bprm->buf, BINPRM_BUF_SIZE, &pos); |
1538 | } | 1537 | } |
1539 | 1538 | ||
1540 | EXPORT_SYMBOL(prepare_binprm); | 1539 | EXPORT_SYMBOL(prepare_binprm); |
diff --git a/fs/read_write.c b/fs/read_write.c index 1ea862bc7efd..9cf1de855b7a 100644 --- a/fs/read_write.c +++ b/fs/read_write.c | |||
@@ -415,17 +415,15 @@ ssize_t __vfs_read(struct file *file, char __user *buf, size_t count, | |||
415 | } | 415 | } |
416 | EXPORT_SYMBOL(__vfs_read); | 416 | EXPORT_SYMBOL(__vfs_read); |
417 | 417 | ||
418 | int kernel_read(struct file *file, loff_t offset, char *addr, | 418 | ssize_t kernel_read(struct file *file, void *buf, size_t count, loff_t *pos) |
419 | unsigned long count) | ||
420 | { | 419 | { |
421 | mm_segment_t old_fs; | 420 | mm_segment_t old_fs; |
422 | loff_t pos = offset; | 421 | ssize_t result; |
423 | int result; | ||
424 | 422 | ||
425 | old_fs = get_fs(); | 423 | old_fs = get_fs(); |
426 | set_fs(get_ds()); | 424 | set_fs(get_ds()); |
427 | /* The cast to a user pointer is valid due to the set_fs() */ | 425 | /* The cast to a user pointer is valid due to the set_fs() */ |
428 | result = vfs_read(file, (void __user *)addr, count, &pos); | 426 | result = vfs_read(file, (void __user *)buf, count, pos); |
429 | set_fs(old_fs); | 427 | set_fs(old_fs); |
430 | return result; | 428 | return result; |
431 | } | 429 | } |
diff --git a/include/linux/fs.h b/include/linux/fs.h index cbfe127bccf8..2ba8f38a4d63 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -2772,13 +2772,13 @@ static inline const char *kernel_read_file_id_str(enum kernel_read_file_id id) | |||
2772 | return kernel_read_file_str[id]; | 2772 | return kernel_read_file_str[id]; |
2773 | } | 2773 | } |
2774 | 2774 | ||
2775 | extern int kernel_read(struct file *, loff_t, char *, unsigned long); | ||
2776 | extern int kernel_read_file(struct file *, void **, loff_t *, loff_t, | 2775 | extern int kernel_read_file(struct file *, void **, loff_t *, loff_t, |
2777 | enum kernel_read_file_id); | 2776 | enum kernel_read_file_id); |
2778 | extern int kernel_read_file_from_path(char *, void **, loff_t *, loff_t, | 2777 | extern int kernel_read_file_from_path(char *, void **, loff_t *, loff_t, |
2779 | enum kernel_read_file_id); | 2778 | enum kernel_read_file_id); |
2780 | extern int kernel_read_file_from_fd(int, void **, loff_t *, loff_t, | 2779 | extern int kernel_read_file_from_fd(int, void **, loff_t *, loff_t, |
2781 | enum kernel_read_file_id); | 2780 | enum kernel_read_file_id); |
2781 | extern ssize_t kernel_read(struct file *, void *, size_t, loff_t *); | ||
2782 | extern ssize_t kernel_write(struct file *, const char *, size_t, loff_t); | 2782 | extern ssize_t kernel_write(struct file *, const char *, size_t, loff_t); |
2783 | extern ssize_t __kernel_write(struct file *, const char *, size_t, loff_t *); | 2783 | extern ssize_t __kernel_write(struct file *, const char *, size_t, loff_t *); |
2784 | extern struct file * open_exec(const char *); | 2784 | extern struct file * open_exec(const char *); |
diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c index 02e1859f2ca8..243fa1c28b4a 100644 --- a/kernel/sysctl_binary.c +++ b/kernel/sysctl_binary.c | |||
@@ -986,8 +986,9 @@ static ssize_t bin_intvec(struct file *file, | |||
986 | size_t length = oldlen / sizeof(*vec); | 986 | size_t length = oldlen / sizeof(*vec); |
987 | char *str, *end; | 987 | char *str, *end; |
988 | int i; | 988 | int i; |
989 | loff_t pos = 0; | ||
989 | 990 | ||
990 | result = kernel_read(file, 0, buffer, BUFSZ - 1); | 991 | result = kernel_read(file, buffer, BUFSZ - 1, &pos); |
991 | if (result < 0) | 992 | if (result < 0) |
992 | goto out_kfree; | 993 | goto out_kfree; |
993 | 994 | ||
@@ -1057,8 +1058,9 @@ static ssize_t bin_ulongvec(struct file *file, | |||
1057 | size_t length = oldlen / sizeof(*vec); | 1058 | size_t length = oldlen / sizeof(*vec); |
1058 | char *str, *end; | 1059 | char *str, *end; |
1059 | int i; | 1060 | int i; |
1061 | loff_t pos = 0; | ||
1060 | 1062 | ||
1061 | result = kernel_read(file, 0, buffer, BUFSZ - 1); | 1063 | result = kernel_read(file, buffer, BUFSZ - 1, &pos); |
1062 | if (result < 0) | 1064 | if (result < 0) |
1063 | goto out_kfree; | 1065 | goto out_kfree; |
1064 | 1066 | ||
@@ -1120,8 +1122,9 @@ static ssize_t bin_uuid(struct file *file, | |||
1120 | if (oldval && oldlen) { | 1122 | if (oldval && oldlen) { |
1121 | char buf[UUID_STRING_LEN + 1]; | 1123 | char buf[UUID_STRING_LEN + 1]; |
1122 | uuid_t uuid; | 1124 | uuid_t uuid; |
1125 | loff_t pos = 0; | ||
1123 | 1126 | ||
1124 | result = kernel_read(file, 0, buf, sizeof(buf) - 1); | 1127 | result = kernel_read(file, buf, sizeof(buf) - 1, &pos); |
1125 | if (result < 0) | 1128 | if (result < 0) |
1126 | goto out; | 1129 | goto out; |
1127 | 1130 | ||
@@ -1154,8 +1157,9 @@ static ssize_t bin_dn_node_address(struct file *file, | |||
1154 | char buf[15], *nodep; | 1157 | char buf[15], *nodep; |
1155 | unsigned long area, node; | 1158 | unsigned long area, node; |
1156 | __le16 dnaddr; | 1159 | __le16 dnaddr; |
1160 | loff_t pos = 0; | ||
1157 | 1161 | ||
1158 | result = kernel_read(file, 0, buf, sizeof(buf) - 1); | 1162 | result = kernel_read(file, buf, sizeof(buf) - 1, &pos); |
1159 | if (result < 0) | 1163 | if (result < 0) |
1160 | goto out; | 1164 | goto out; |
1161 | 1165 | ||
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c index ddfa86648f95..f12815777beb 100644 --- a/net/9p/trans_fd.c +++ b/net/9p/trans_fd.c | |||
@@ -272,6 +272,7 @@ static int p9_fd_read(struct p9_client *client, void *v, int len) | |||
272 | { | 272 | { |
273 | int ret; | 273 | int ret; |
274 | struct p9_trans_fd *ts = NULL; | 274 | struct p9_trans_fd *ts = NULL; |
275 | loff_t pos; | ||
275 | 276 | ||
276 | if (client && client->status != Disconnected) | 277 | if (client && client->status != Disconnected) |
277 | ts = client->trans; | 278 | ts = client->trans; |
@@ -282,7 +283,8 @@ static int p9_fd_read(struct p9_client *client, void *v, int len) | |||
282 | if (!(ts->rd->f_flags & O_NONBLOCK)) | 283 | if (!(ts->rd->f_flags & O_NONBLOCK)) |
283 | p9_debug(P9_DEBUG_ERROR, "blocking read ...\n"); | 284 | p9_debug(P9_DEBUG_ERROR, "blocking read ...\n"); |
284 | 285 | ||
285 | ret = kernel_read(ts->rd, ts->rd->f_pos, v, len); | 286 | pos = ts->rd->f_pos; |
287 | ret = kernel_read(ts->rd, v, len, &pos); | ||
286 | if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN) | 288 | if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN) |
287 | client->status = Disconnected; | 289 | client->status = Disconnected; |
288 | return ret; | 290 | return ret; |
diff --git a/security/keys/big_key.c b/security/keys/big_key.c index 835c1ab30d01..9f4c86cade8e 100644 --- a/security/keys/big_key.c +++ b/security/keys/big_key.c | |||
@@ -295,6 +295,7 @@ long big_key_read(const struct key *key, char __user *buffer, size_t buflen) | |||
295 | u8 *data; | 295 | u8 *data; |
296 | u8 *enckey = (u8 *)key->payload.data[big_key_data]; | 296 | u8 *enckey = (u8 *)key->payload.data[big_key_data]; |
297 | size_t enclen = ALIGN(datalen, crypto_skcipher_blocksize(big_key_skcipher)); | 297 | size_t enclen = ALIGN(datalen, crypto_skcipher_blocksize(big_key_skcipher)); |
298 | loff_t pos = 0; | ||
298 | 299 | ||
299 | data = kmalloc(enclen, GFP_KERNEL); | 300 | data = kmalloc(enclen, GFP_KERNEL); |
300 | if (!data) | 301 | if (!data) |
@@ -307,7 +308,7 @@ long big_key_read(const struct key *key, char __user *buffer, size_t buflen) | |||
307 | } | 308 | } |
308 | 309 | ||
309 | /* read file to kernel and decrypt */ | 310 | /* read file to kernel and decrypt */ |
310 | ret = kernel_read(file, 0, data, enclen); | 311 | ret = kernel_read(file, data, enclen, &pos); |
311 | if (ret >= 0 && ret != enclen) { | 312 | if (ret >= 0 && ret != enclen) { |
312 | ret = -EIO; | 313 | ret = -EIO; |
313 | goto err_fput; | 314 | goto err_fput; |