diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-09-14 21:13:32 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-09-14 21:13:32 -0400 |
| commit | 581bfce969cbfc7ce43ee92273be9cb7c3fdfa61 (patch) | |
| tree | 0a693778ce39c49b9b7d93d0d6795c576896f5cf | |
| parent | cc73fee0bae2d66594d1fa2df92bbd783aa98e04 (diff) | |
| parent | 9725d4cef62229b4ec4c912e0db0761e7d400650 (diff) | |
Merge branch 'work.set_fs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull more set_fs removal from Al Viro:
"Christoph's 'use kernel_read and friends rather than open-coding
set_fs()' series"
* 'work.set_fs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
fs: unexport vfs_readv and vfs_writev
fs: unexport vfs_read and vfs_write
fs: unexport __vfs_read/__vfs_write
lustre: switch to kernel_write
gadget/f_mass_storage: stop messing with the address limit
mconsole: switch to kernel_read
btrfs: switch write_buf to kernel_write
net/9p: switch p9_fd_read to kernel_write
mm/nommu: switch do_mmap_private to kernel_read
serial2002: switch serial2002_tty_write to kernel_{read/write}
fs: make the buf argument to __kernel_write a void pointer
fs: fix kernel_write prototype
fs: fix kernel_read prototype
fs: move kernel_read to fs/read_write.c
fs: move kernel_write to fs/read_write.c
autofs4: switch autofs4_write to __kernel_write
ashmem: switch to ->read_iter
31 files changed, 147 insertions, 236 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/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c index af326fb6510d..c4d162a94be9 100644 --- a/arch/um/drivers/mconsole_kern.c +++ b/arch/um/drivers/mconsole_kern.c | |||
| @@ -148,12 +148,7 @@ void mconsole_proc(struct mc_request *req) | |||
| 148 | } | 148 | } |
| 149 | 149 | ||
| 150 | do { | 150 | do { |
| 151 | loff_t pos = file->f_pos; | 151 | len = kernel_read(file, buf, PAGE_SIZE - 1, &file->f_pos); |
| 152 | mm_segment_t old_fs = get_fs(); | ||
| 153 | set_fs(KERNEL_DS); | ||
| 154 | len = vfs_read(file, buf, PAGE_SIZE - 1, &pos); | ||
| 155 | set_fs(old_fs); | ||
| 156 | file->f_pos = pos; | ||
| 157 | if (len < 0) { | 152 | if (len < 0) { |
| 158 | mconsole_reply(req, "Read of file failed", 1, 0); | 153 | mconsole_reply(req, "Read of file failed", 1, 0); |
| 159 | goto out_free; | 154 | goto out_free; |
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 fec613221958..246b4393118e 100644 --- a/drivers/mtd/nand/nandsim.c +++ b/drivers/mtd/nand/nandsim.c | |||
| @@ -1356,7 +1356,7 @@ static ssize_t read_file(struct nandsim *ns, struct file *file, void *buf, size_ | |||
