History

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

Linus Torvalds committed 9 years ago

Commit 581bfce2 parents cc73fee 9725d4c31 files · +147 −236Browse files

Unified · Split

31 files
  1. arch/mips/kernel/elf.c +4 −8
  2. arch/um/drivers/mconsole_kern.c +1 −6
  3. arch/x86/ia32/ia32_aout.c +2 −2
  4. drivers/media/pci/cx25821/cx25821-audio-upstream.c +5 −8
  5. drivers/mtd/nand/nandsim.c +2 −2
  6. drivers/staging/android/ashmem.c +8 −21
  7. drivers/staging/comedi/drivers/serial2002.c +5 −19
  8. drivers/staging/lustre/lnet/libcfs/tracefile.c +2 −8
  9. drivers/staging/lustre/lustre/obdclass/kernelcomm.c +1 −6
  10. drivers/target/target_core_alua.c +2 −1
  11. drivers/target/target_core_file.c +1 −1
  12. drivers/target/target_core_pr.c +2 −1
  13. drivers/usb/gadget/function/f_mass_storage.c +6 −15
  14. fs/autofs4/waitq.c +1 −8
  15. fs/binfmt_aout.c +2 −1
  16. fs/binfmt_elf.c +13 −10
  17. fs/binfmt_elf_fdpic.c +9 −8
  18. fs/binfmt_flat.c +5 −13
  19. fs/binfmt_misc.c +4 −1
  20. fs/btrfs/send.c +4 −14
  21. fs/coda/dir.c +3 −2
  22. fs/ecryptfs/read_write.c +2 −2
  23. fs/exec.c +3 −21
  24. fs/read_write.c +32 −11
  25. fs/splice.c +0 −16
  26. include/linux/fs.h +3 −6
  27. kernel/acct.c +1 −1
  28. kernel/sysctl_binary.c +14 −7
  29. mm/nommu.c +1 −6
  30. net/9p/trans_fd.c +5 −9
  31. security/keys/big_key.c +4 −2
arch/mips/kernel/elf.c+4−8
@@ -87,6 +87,7 @@ int arch_elf_pt_proc(void *_ehdr, void *_phdr, struct file *elf, · 86 unmodified lines
8787 bool elf32;
8888 u32 flags;
8989 int ret;
90+ loff_t pos;
9091
9192 elf32 = ehdr->e32.e_ident[EI_CLASS] == ELFCLASS32;
9293 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, · 15 unmodified lines
108109
109110 if (phdr32->p_filesz < sizeof(abiflags))
110111 return -EINVAL;
111−
112− ret = kernel_read(elf, phdr32->p_offset,
113− (char *)&abiflags,
114− sizeof(abiflags));
112+ pos = phdr32->p_offset;
115113 } else {
116114 if (phdr64->p_type != PT_MIPS_ABIFLAGS)
117115 return 0;
118116 if (phdr64->p_filesz < sizeof(abiflags))
119117 return -EINVAL;
120−
121− ret = kernel_read(elf, phdr64->p_offset,
122− (char *)&abiflags,
123− sizeof(abiflags));
118+ pos = phdr64->p_offset;
124119 }
125120
121+ ret = kernel_read(elf, &abiflags, sizeof(abiflags), &pos);
126122 if (ret < 0)
127123 return ret;
128124 if (ret != sizeof(abiflags))
arch/um/drivers/mconsole_kern.c+1−6
@@ -148,12 +148,7 @@ void mconsole_proc(struct mc_request *req) · 147 unmodified lines
148148 }
149149
150150 do {
151− loff_t pos = 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;
151+ len = kernel_read(file, buf, PAGE_SIZE - 1, &file->f_pos);
157152 if (len < 0) {
158153 mconsole_reply(req, "Read of file failed", 1, 0);
159154 goto out_free;
arch/x86/ia32/ia32_aout.c+2−2
@@ -407,10 +407,10 @@ static int load_aout_library(struct file *file) · 406 unmodified lines
407407 unsigned long bss, start_addr, len, error;
408408 int retval;
409409 struct exec ex;
410−
410+ loff_t pos = 0;
411411
412412 retval = -ENOEXEC;
413− error = kernel_read(file, 0, (char *) &ex, sizeof(ex));
413+ error = kernel_read(file, &ex, sizeof(ex), &pos);
414414 if (error != sizeof(ex))
415415 goto out;
416416
drivers/media/pci/cx25821/cx25821-audio-upstream.c+5−8
@@ -277,7 +277,7 @@ static int cx25821_get_audio_data(struct cx25821_dev *dev, · 276 unmodified lines
277277 p = (char *)dev->_audiodata_buf_virt_addr + frame_offset;
278278
279279 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);
281281 if (n < AUDIO_LINE_SIZE) {
282282 pr_info("Done: exit %s() since no more bytes to read from Audio file\n",
283283 __func__);
@@ -290,7 +290,6 @@ static int cx25821_get_audio_data(struct cx25821_dev *dev, · 6 unmodified lines
290290 memcpy(p, mybuf, n);
291291 p += n;
292292 }
293− file_offset += n;
294293 }
295294 dev->_audioframe_count++;
296295 fput(file);
@@ -318,7 +317,7 @@ static int cx25821_openfile_audio(struct cx25821_dev *dev, · 21 unmodified lines
318317 {
319318 char *p = (void *)dev->_audiodata_buf_virt_addr;
320319 struct file *file;
321− loff_t offset;
320+ loff_t file_offset = 0;
322321 int i, j;
323322
324323 file = filp_open(dev->_audiofilename, O_RDONLY | O_LARGEFILE, 0);
@@ -328,11 +327,11 @@ static int cx25821_openfile_audio(struct cx25821_dev *dev, · 3 unmodified lines
328327 return PTR_ERR(file);
329328 }
330329
331− for (j = 0, offset = 0; j < NUM_AUDIO_FRAMES; j++) {
330+ for (j = 0; j < NUM_AUDIO_FRAMES; j++) {
332331 for (i = 0; i < dev->_audio_lines_count; i++) {
333332 char buf[AUDIO_LINE_SIZE];
334− int n = kernel_read(file, offset, buf,
335− AUDIO_LINE_SIZE);
333+ loff_t offset = file_offset;
334+ int n = kernel_read(file, buf, AUDIO_LINE_SIZE, &file_offset);
336335
337336 if (n < AUDIO_LINE_SIZE) {
338337 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, · 5 unmodified lines
344343
345344 if (p)
346345 memcpy(p + offset, buf, n);
347−
348− offset += n;
349346 }
350347 dev->_audioframe_count++;
351348 }
drivers/mtd/nand/nandsim.c+2−2
@@ -1356,7 +1356,7 @@ static ssize_t read_file(struct nandsim *ns, struct file *file, void *buf, size_ · 1355 unmodified lines
13561356 if (err)
13571357 return err;
13581358 noreclaim_flag = memalloc_noreclaim_save();
1359− tx = kernel_read(file, pos, buf, count);
1359+ tx = kernel_read(file, buf, count, &pos);
13601360 memalloc_noreclaim_restore(noreclaim_flag);
13611361 put_pages(ns);
13621362 return tx;
@@ -1372,7 +1372,7 @@ static ssize_t write_file(struct nandsim *ns, struct file *file, void *buf, size · 9 unmodified lines
13721372 if (err)
13731373 return err;
13741374 noreclaim_flag = memalloc_noreclaim_save();
1375− tx = kernel_write(file, buf, count, pos);
1375+ tx = kernel_write(file, buf, count, &pos);
13761376 memalloc_noreclaim_restore(noreclaim_flag);
13771377 put_pages(ns);
13781378 return tx;
drivers/staging/android/ashmem.c+8−21
@@ -294,19 +294,9 @@ static int ashmem_release(struct inode *ignored, struct file *file) · 293 unmodified lines
294294 return 0;
295295 }
296296
297−/**
298− * ashmem_read() - Reads a set of bytes from an Ashmem-enabled file
299− * @file: The associated backing file.
300− * @buf: The buffer of data being written to
301− * @len: The number of bytes being read
302− * @pos: The position of the first byte to read.
303− *
304− * Return: 0 if successful, or another return code if not.
305− */
306−static ssize_t ashmem_read(struct file *file, char __user *buf,
307− size_t len, loff_t *pos)
297+static ssize_t ashmem_read_iter(struct kiocb *iocb, struct iov_iter *iter)
308298 {
309− struct ashmem_area *asma = file->private_data;
299+ struct ashmem_area *asma = iocb->ki_filp->private_data;
310300 int ret = 0;
311301
312302 mutex_lock(&ashmem_mutex);
@@ -320,20 +310,17 @@ static ssize_t ashmem_read(struct file *file, char __user *buf, · 7 unmodified lines
320310 goto out_unlock;
321311 }
322312
323− mutex_unlock(&ashmem_mutex);
324−
325313 /*
326314 * asma and asma->file are used outside the lock here. We assume
327315 * once asma->file is set it will never be changed, and will not
328316 * be destroyed until all references to the file are dropped and
329317 * ashmem_release is called.
330318 */
331− ret = __vfs_read(asma->file, buf, len, pos);
332− if (ret >= 0)
333− /** Update backing file pos, since f_ops->read() doesn't */
334− asma->file->f_pos = *pos;
335− return ret;
336−
319+ mutex_unlock(&ashmem_mutex);
320+ ret = vfs_iter_read(asma->file, iter, &iocb->ki_pos, 0);
321+ mutex_lock(&ashmem_mutex);
322+ if (ret > 0)
323+ asma->file->f_pos = iocb->ki_pos;
337324 out_unlock:
338325 mutex_unlock(&ashmem_mutex);
339326 return ret;
@@ -834,7 +821,7 @@ static const struct file_operations ashmem_fops = { · 494 unmodified lines
834821 .owner = THIS_MODULE,
835822 .open = ashmem_open,
836823 .release = ashmem_release,
837− .read = ashmem_read,
824+ .read_iter = ashmem_read_iter,
838825 .llseek = ashmem_llseek,
839826 .mmap = ashmem_mmap,
840827 .unlocked_ioctl = ashmem_ioctl,
drivers/staging/comedi/drivers/serial2002.c+5−19
@@ -106,16 +106,8 @@ static long serial2002_tty_ioctl(struct file *f, unsigned int op, · 105 unmodified lines
106106
107107 static int serial2002_tty_write(struct file *f, unsigned char *buf, int count)
108108 {
109− const char __user *p = (__force const char __user *)buf;
110− int result;
111− loff_t offset = 0;
112− mm_segment_t oldfs;
113−
114− oldfs = get_fs();
115− set_fs(KERNEL_DS);
116− result = __vfs_write(f, p, count, &offset);
117− set_fs(oldfs);
118− return result;
109+ loff_t pos = 0;
110+ return kernel_write(f, buf, count, &pos);
119111 }
120112
121113 static void serial2002_tty_read_poll_wait(struct file *f, int timeout)
@@ -148,19 +140,14 @@ static int serial2002_tty_read(struct file *f, int timeout) · 26 unmodified lines
148140 {
149141 unsigned char ch;
150142 int result;
143+ loff_t pos = 0;
151144
152145 result = -1;
153146 if (!IS_ERR(f)) {
154− mm_segment_t oldfs;
155− char __user *p = (__force char __user *)&ch;
156− loff_t offset = 0;
157−
158− oldfs = get_fs();
159− set_fs(KERNEL_DS);
160147 if (f->f_op->poll) {
161148 serial2002_tty_read_poll_wait(f, timeout);
162149
163− if (__vfs_read(f, p, 1, &offset) == 1)
150+ if (kernel_read(f, &ch, 1, &pos) == 1)
164151 result = ch;
165152 } else {
166153 /* Device does not support poll, busy wait */
@@ -171,14 +158,13 @@ static int serial2002_tty_read(struct file *f, int timeout) · 4 unmodified lines
171158 if (retries >= timeout)
172159 break;
173160
174− if (__vfs_read(f, p, 1, &offset) == 1) {
161+ if (kernel_read(f, &ch, 1, &pos) == 1) {
175162 result = ch;
176163 break;
177164 }
178165 usleep_range(100, 1000);
179166 }
180167 }
181− set_fs(oldfs);
182168 }
183169 return result;
184170 }
drivers/staging/lustre/lnet/libcfs/tracefile.c+2−8
@@ -731,8 +731,7 @@ int cfs_tracefile_dump_all_pages(char *filename) · 730 unmodified lines
731731 __LASSERT_TAGE_INVARIANT(tage);
732732
733733 buf = kmap(tage->page);
734− rc = vfs_write(filp, (__force const char __user *)buf,
735− tage->used, &filp->f_pos);
734+ rc = kernel_write(filp, buf, tage->used, &filp->f_pos);
736735 kunmap(tage->page);
737736
738737 if (rc != (int)tage->used) {
@@ -976,7 +975,6 @@ static int tracefiled(void *arg) · 237 unmodified lines
976975 struct tracefiled_ctl *tctl = arg;
977976 struct cfs_trace_page *tage;
978977 struct cfs_trace_page *tmp;
979− mm_segment_t __oldfs;
980978 struct file *filp;
981979 char *buf;
982980 int last_loop = 0;
@@ -1014,8 +1012,6 @@ static int tracefiled(void *arg) · 31 unmodified lines
10141012 __LASSERT(list_empty(&pc.pc_pages));
10151013 goto end_loop;
10161014 }
1017− __oldfs = get_fs();
1018− set_fs(get_ds());
10191015
10201016 list_for_each_entry_safe(tage, tmp, &pc.pc_pages, linkage) {
10211017 static loff_t f_pos;
@@ -1028,8 +1024,7 @@ static int tracefiled(void *arg) · 6 unmodified lines
10281024 f_pos = i_size_read(file_inode(filp));
10291025
10301026 buf = kmap(tage->page);
1031− rc = vfs_write(filp, (__force const char __user *)buf,
1032− tage->used, &f_pos);
1027+ rc = kernel_write(filp, buf, tage->used, &f_pos);
10331028 kunmap(tage->page);
10341029
10351030 if (rc != (int)tage->used) {
@@ -1040,7 +1035,6 @@ static int tracefiled(void *arg) · 4 unmodified lines
10401035 break;
10411036 }
10421037 }
1043− set_fs(__oldfs);
10441038
10451039 filp_close(filp, NULL);
10461040 put_pages_on_daemon_list(&pc);
drivers/staging/lustre/lustre/obdclass/kernelcomm.c+1−6
@@ -52,7 +52,6 @@ int libcfs_kkuc_msg_put(struct file *filp, void *payload) · 51 unmodified lines
5252 struct kuc_hdr *kuch = (struct kuc_hdr *)payload;
5353 ssize_t count = kuch->kuc_msglen;
5454 loff_t offset = 0;
55− mm_segment_t fs;
5655 int rc = -ENXIO;
5756
5857 if (IS_ERR_OR_NULL(filp))
@@ -63,18 +62,14 @@ int libcfs_kkuc_msg_put(struct file *filp, void *payload) · 4 unmodified lines
6362 return rc;
6463 }
6564
66− fs = get_fs();
67− set_fs(KERNEL_DS);
6865 while (count > 0) {
69− rc = vfs_write(filp, (void __force __user *)payload,
70− count, &offset);
66+ rc = kernel_write(filp, payload, count, &offset);
7167 if (rc < 0)
7268 break;
7369 count -= rc;
7470 payload += rc;
7571 rc = 0;
7672 }
77− set_fs(fs);
7873
7974 if (rc < 0)
8075 CWARN("message send failed (%d)\n", rc);
drivers/target/target_core_alua.c+2−1
@@ -896,13 +896,14 @@ static int core_alua_write_tpg_metadata( · 895 unmodified lines
896896 u32 md_buf_len)
897897 {
898898 struct file *file = filp_open(path, O_RDWR | O_CREAT | O_TRUNC, 0600);
899+ loff_t pos = 0;
899900 int ret;
900901
901902 if (IS_ERR(file)) {
902903 pr_err("filp_open(%s) for ALUA metadata failed\n", path);
903904 return -ENODEV;
904905 }
905− ret = kernel_write(file, md_buf, md_buf_len, 0);
906+ ret = kernel_write(file, md_buf, md_buf_len, &pos);
906907 if (ret < 0)
907908 pr_err("Error writing ALUA metadata file: %s\n", path);
908909 fput(file);
drivers/target/target_core_file.c+1−1
@@ -443,7 +443,7 @@ fd_do_prot_fill(struct se_device *se_dev, sector_t lba, sector_t nolb, · 442 unmodified lines
443443
444444 for (prot = 0; prot < prot_length;) {
445445 sector_t len = min_t(sector_t, bufsize, prot_length - prot);
446− ssize_t ret = kernel_write(prot_fd, buf, len, pos + prot);
446+ ssize_t ret = kernel_write(prot_fd, buf, len, &pos);
447447
448448 if (ret != len) {
449449 pr_err("vfs_write to prot file failed: %zd\n", ret);
drivers/target/target_core_pr.c+2−1
@@ -1974,6 +1974,7 @@ static int __core_scsi3_write_aptpl_to_file( · 1973 unmodified lines
19741974 char path[512];
19751975 u32 pr_aptpl_buf_len;
19761976 int ret;
1977+ loff_t pos = 0;
19771978
19781979 memset(path, 0, 512);
19791980
@@ -1993,7 +1994,7 @@ static int __core_scsi3_write_aptpl_to_file( · 13 unmodified lines
19931994
19941995 pr_aptpl_buf_len = (strlen(buf) + 1); /* Add extra for NULL */
19951996
1996− ret = kernel_write(file, buf, pr_aptpl_buf_len, 0);
1997+ ret = kernel_write(file, buf, pr_aptpl_buf_len, &pos);
19971998
19981999 if (ret < 0)
19992000 pr_debug("Error writing APTPL metadata file: %s\n", path);
drivers/usb/gadget/function/f_mass_storage.c+6−15
@@ -686,9 +686,8 @@ static int do_read(struct fsg_common *common) · 685 unmodified lines
686686
687687 /* Perform the read */
688688 file_offset_tmp = file_offset;
689− nread = vfs_read(curlun->filp,
690− (char __user *)bh->buf,
691− amount, &file_offset_tmp);
689+ nread = kernel_read(curlun->filp, bh->buf, amount,
690+ &file_offset_tmp);
692691 VLDBG(curlun, "file read %u @ %llu -> %d\n", amount,
693692 (unsigned long long)file_offset, (int)nread);
694693 if (signal_pending(current))
@@ -883,8 +882,8 @@ static int do_write(struct fsg_common *common) · 188 unmodified lines
883882
884883 /* Perform the write */
885884 file_offset_tmp = file_offset;
886− nwritten = vfs_write(curlun->filp, (char __user *)bh->buf,
887− amount, &file_offset_tmp);
885+ nwritten = kernel_write(curlun->filp, bh->buf, amount,
886+ &file_offset_tmp);
888887 VLDBG(curlun, "file write %u @ %llu -> %d\n", amount,
889888 (unsigned long long)file_offset, (int)nwritten);
890889 if (signal_pending(current))
@@ -1021,9 +1020,8 @@ static int do_verify(struct fsg_common *common) · 130 unmodified lines
10211020
10221021 /* Perform the read */
10231022 file_offset_tmp = file_offset;
1024− nread = vfs_read(curlun->filp,
1025− (char __user *) bh->buf,
1026− amount, &file_offset_tmp);
1023+ nread = kernel_read(curlun->filp, bh->buf, amount,
1024+ &file_offset_tmp);
10271025 VLDBG(curlun, "file read %u @ %llu -> %d\n", amount,
10281026 (unsigned long long) file_offset,
10291027 (int) nread);
@@ -2453,13 +2451,6 @@ static int fsg_main_thread(void *common_) · 1423 unmodified lines
24532451 /* Allow the thread to be frozen */
24542452 set_freezable();
24552453
2456− /*
2457− * Arrange for userspace references to be interpreted as kernel
2458− * pointers. That way we can pass a kernel pointer to a routine
2459− * that expects a __user pointer and it will work okay.
2460− */
2461− set_fs(get_ds());
2462−
24632454 /* The main loop */
24642455 while (common->state != FSG_STATE_TERMINATED) {
24652456 if (exception_in_progress(common) || signal_pending(current)) {
fs/autofs4/waitq.c+1−8
@@ -56,19 +56,14 @@ static int autofs4_write(struct autofs_sb_info *sbi, · 55 unmodified lines
5656 struct file *file, const void *addr, int bytes)
5757 {
5858 unsigned long sigpipe, flags;
59− mm_segment_t fs;
6059 const char *data = (const char *)addr;
6160 ssize_t wr = 0;
6261
6362 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
6463
65− /* Save pointer to user space and point back to kernel space */
66− fs = get_fs();
67− set_fs(KERNEL_DS);
68−
6964 mutex_lock(&sbi->pipe_mutex);
7065 while (bytes) {
71− wr = __vfs_write(file, data, bytes, &file->f_pos);
66+ wr = __kernel_write(file, data, bytes, &file->f_pos);
7267 if (wr <= 0)
7368 break;
7469 data += wr;
@@ -76,8 +71,6 @@ static int autofs4_write(struct autofs_sb_info *sbi, · 1 unmodified line
7671 }
7772 mutex_unlock(&sbi->pipe_mutex);
7873
79− set_fs(fs);
80−
8174 /* Keep the currently executing process from receiving a
8275 * SIGPIPE unless it was already supposed to get one
8376 */
fs/binfmt_aout.c+2−1
@@ -341,11 +341,12 @@ static int load_aout_library(struct file *file) · 340 unmodified lines
341341 unsigned long error;
342342 int retval;
343343 struct exec ex;
344+ loff_t pos = 0;
344345
345346 inode = file_inode(file);
346347
347348 retval = -ENOEXEC;
348− error = kernel_read(file, 0, (char *) &ex, sizeof(ex));
349+ error = kernel_read(file, &ex, sizeof(ex), &pos);
349350 if (error != sizeof(ex))
350351 goto out;
351352
fs/binfmt_elf.c+13−10
@@ -409,6 +409,7 @@ static struct elf_phdr *load_elf_phdrs(struct elfhdr *elf_ex, · 408 unmodified lines
409409 {
410410 struct elf_phdr *elf_phdata = NULL;
411411 int retval, size, err = -1;
412+ loff_t pos = elf_ex->e_phoff;
412413
413414 /*
414415 * 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, · 17 unmodified lines
432433 goto out;
433434
434435 /* Read in the program headers */
435− retval = kernel_read(elf_file, elf_ex->e_phoff,
436− (char *)elf_phdata, size);
436+ retval = kernel_read(elf_file, elf_phdata, size, &pos);
437437 if (retval != size) {
438438 err = (retval < 0) ? retval : -EIO;
439439 goto out;
@@ -698,6 +698,7 @@ static int load_elf_binary(struct linux_binprm *bprm) · 258 unmodified lines
698698 struct elfhdr interp_elf_ex;
699699 } *loc;
700700 struct arch_elf_state arch_state = INIT_ARCH_ELF_STATE;
701+ loff_t pos;
701702
702703 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
703704 if (!loc) {
@@ -750,9 +751,9 @@ static int load_elf_binary(struct linux_binprm *bprm) · 46 unmodified lines
750751 if (!elf_interpreter)
751752 goto out_free_ph;
752753
753− retval = kernel_read(bprm->file, elf_ppnt->p_offset,
754− elf_interpreter,
755− elf_ppnt->p_filesz);
754+ pos = elf_ppnt->p_offset;
755+ retval = kernel_read(bprm->file, elf_interpreter,
756+ elf_ppnt->p_filesz, &pos);
756757 if (retval != elf_ppnt->p_filesz) {
757758 if (retval >= 0)
758759 retval = -EIO;
@@ -776,9 +777,9 @@ static int load_elf_binary(struct linux_binprm *bprm) · 17 unmodified lines
776777 would_dump(bprm, interpreter);
777778
778779 /* Get the exec headers */
779− retval = kernel_read(interpreter, 0,
780− (void *)&loc->interp_elf_ex,
781− sizeof(loc->interp_elf_ex));
780+ pos = 0;
781+ retval = kernel_read(interpreter, &loc->interp_elf_ex,
782+ sizeof(loc->interp_elf_ex), &pos);
782783 if (retval != sizeof(loc->interp_elf_ex)) {
783784 if (retval >= 0)
784785 retval = -EIO;
@@ -1175,9 +1176,10 @@ static int load_elf_library(struct file *file) · 390 unmodified lines
11751176 unsigned long elf_bss, bss, len;
11761177 int retval, error, i, j;
11771178 struct elfhdr elf_ex;
1179+ loff_t pos = 0;
11781180
11791181 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);
11811183 if (retval != sizeof(elf_ex))
11821184 goto out;
11831185
@@ -1201,7 +1203,8 @@ static int load_elf_library(struct file *file) · 17 unmodified lines
12011203
12021204 eppnt = elf_phdata;
12031205 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);
12051208 if (retval != j)
12061209 goto out_free_ph;
12071210
fs/binfmt_elf_fdpic.c+9−8
@@ -145,6 +145,7 @@ static int elf_fdpic_fetch_phdrs(struct elf_fdpic_params *params, · 144 unmodified lines
145145 struct elf32_phdr *phdr;
146146 unsigned long size;
147147 int retval, loop;
148+ loff_t pos = params->hdr.e_phoff;
148149
149150 if (params->hdr.e_phentsize != sizeof(struct elf_phdr))
150151 return -ENOMEM;
@@ -156,8 +157,7 @@ static int elf_fdpic_fetch_phdrs(struct elf_fdpic_params *params, · 5 unmodified lines
156157 if (!params->phdrs)
157158 return -ENOMEM;
158159
159− retval = kernel_read(file, params->hdr.e_phoff,
160− (char *) params->phdrs, size);
160+ retval = kernel_read(file, params->phdrs, size, &pos);
161161 if (unlikely(retval != size))
162162 return retval < 0 ? retval : -ENOEXEC;
163163
@@ -199,6 +199,7 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm) · 35 unmodified lines
199199 char *interpreter_name = NULL;
200200 int executable_stack;
201201 int retval, i;
202+ loff_t pos;
202203
203204 kdebug("____ LOAD %d ____", current->pid);
204205
@@ -246,10 +247,9 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm) · 41 unmodified lines
246247 if (!interpreter_name)
247248 goto error;
248249
249− retval = kernel_read(bprm->file,
250− phdr->p_offset,
251− interpreter_name,
252− phdr->p_filesz);
250+ pos = phdr->p_offset;
251+ retval = kernel_read(bprm->file, interpreter_name,
252+ phdr->p_filesz, &pos);
253253 if (unlikely(retval != phdr->p_filesz)) {
254254 if (retval >= 0)
255255 retval = -ENOEXEC;
@@ -277,8 +277,9 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm) · 21 unmodified lines
277277 */
278278 would_dump(bprm, interpreter);
279279
280− retval = kernel_read(interpreter, 0, bprm->buf,
281− BINPRM_BUF_SIZE);
280+ pos = 0;
281+ retval = kernel_read(interpreter, bprm->buf,
282+ BINPRM_BUF_SIZE, &pos);
282283 if (unlikely(retval != BINPRM_BUF_SIZE)) {
283284 if (retval >= 0)
284285 retval = -ENOEXEC;
fs/binfmt_flat.c+5−13
@@ -176,19 +176,14 @@ static int create_flat_tables(struct linux_binprm *bprm, unsigned long arg_start · 175 unmodified lines
176176 #define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
177177 #define RESERVED 0xC0 /* bit 6,7: reserved */
178178
179−static int decompress_exec(
180− struct linux_binprm *bprm,
181− unsigned long offset,
182− char *dst,
183− long len,
184− int fd)
179+static int decompress_exec(struct linux_binprm *bprm, loff_t fpos, char *dst,
180+ long len, int fd)
185181 {
186182 unsigned char *buf;
187183 z_stream strm;
188− loff_t fpos;
189184 int ret, retval;
190185
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);
192187
193188 memset(&strm, 0, sizeof(strm));
194189 strm.workspace = kmalloc(zlib_inflate_workspacesize(), GFP_KERNEL);
@@ -202,13 +197,11 @@ static int decompress_exec( · 7 unmodified lines
202197 }
203198
204199 /* Read in first chunk of data and parse gzip header. */
205− fpos = offset;
206− ret = kernel_read(bprm->file, offset, buf, LBUFSIZE);
200+ ret = kernel_read(bprm->file, buf, LBUFSIZE, &fpos);
207201
208202 strm.next_in = buf;
209203 strm.avail_in = ret;
210204 strm.total_in = 0;
211− fpos += ret;
212205
213206 retval = -ENOEXEC;
214207
@@ -274,7 +267,7 @@ static int decompress_exec( · 59 unmodified lines
274267 }
275268
276269 while ((ret = zlib_inflate(&strm, Z_NO_FLUSH)) == Z_OK) {
277− ret = kernel_read(bprm->file, fpos, buf, LBUFSIZE);
270+ ret = kernel_read(bprm->file, buf, LBUFSIZE, &fpos);
278271 if (ret <= 0)
279272 break;
280273 len -= ret;
@@ -282,7 +275,6 @@ static int decompress_exec( · 1 unmodified line
282275 strm.next_in = buf;
283276 strm.avail_in = ret;
284277 strm.total_in = 0;
285− fpos += ret;
286278 }
287279
288280 if (ret < 0) {
fs/binfmt_misc.c+4−1
@@ -218,12 +218,15 @@ static int load_misc_binary(struct linux_binprm *bprm) · 217 unmodified lines
218218
219219 bprm->file = interp_file;
220220 if (fmt->flags & MISC_FMT_CREDENTIALS) {
221+ loff_t pos = 0;
222+
221223 /*
222224 * No need to call prepare_binprm(), it's already been
223225 * done. bprm->buf is stale, update from interp_file.
224226 */
225227 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);
227230 } else
228231 retval = prepare_binprm(bprm);
229232
fs/btrfs/send.c+4−14
@@ -539,33 +539,23 @@ static struct btrfs_path *alloc_path_for_send(void) · 538 unmodified lines
539539 static int write_buf(struct file *filp, const void *buf, u32 len, loff_t *off)
540540 {
541541 int ret;
542− mm_segment_t old_fs;
543542 u32 pos = 0;
544543
545− old_fs = get_fs();
546− set_fs(KERNEL_DS);
547−
548544 while (pos < len) {
549− ret = vfs_write(filp, (__force const char __user *)buf + pos,
550− len - pos, off);
545+ ret = kernel_write(filp, buf + pos, len - pos, off);
551546 /* TODO handle that correctly */
552547 /*if (ret == -ERESTARTSYS) {
553548 continue;
554549 }*/
555550 if (ret < 0)
556− goto out;
551+ return ret;
557552 if (ret == 0) {
558− ret = -EIO;
559− goto out;
553+ return -EIO;
560554 }
561555 pos += ret;
562556 }
563557
564− ret = 0;
565−
566−out:
567− set_fs(old_fs);
568− return ret;
558+ return 0;
569559 }
570560
571561 static int tlv_put(struct send_ctx *sctx, u16 attr, const void *data, int len)
fs/coda/dir.c+3−2
@@ -368,9 +368,10 @@ static int coda_venus_readdir(struct file *coda_file, struct dir_context *ctx) · 367 unmodified lines
368368 goto out;
369369
370370 while (1) {
371+ loff_t pos = ctx->pos - 2;
372+
371373 /* read entries from the directory file */
372− ret = kernel_read(host_file, ctx->pos - 2, (char *)vdir,
373− sizeof(*vdir));
374+ ret = kernel_read(host_file, vdir, sizeof(*vdir), &pos);
374375 if (ret < 0) {
375376 pr_err("%s: read dir %s failed %d\n",
376377 __func__, coda_f2s(&cii->c_fid), ret);
fs/ecryptfs/read_write.c+2−2
@@ -47,7 +47,7 @@ int ecryptfs_write_lower(struct inode *ecryptfs_inode, char *data, · 46 unmodified lines
4747 lower_file = ecryptfs_inode_to_private(ecryptfs_inode)->lower_file;
4848 if (!lower_file)
4949 return -EIO;
50− rc = kernel_write(lower_file, data, size, offset);
50+ rc = kernel_write(lower_file, data, size, &offset);
5151 mark_inode_dirty_sync(ecryptfs_inode);
5252 return rc;
5353 }
@@ -237,7 +237,7 @@ int ecryptfs_read_lower(char *data, loff_t offset, size_t size, · 183 unmodified lines
237237 lower_file = ecryptfs_inode_to_private(ecryptfs_inode)->lower_file;
238238 if (!lower_file)
239239 return -EIO;
240− return kernel_read(lower_file, offset, data, size);
240+ return kernel_read(lower_file, data, size, &offset);
241241 }
242242
243243 /**
fs/exec.c+3−21
@@ -885,23 +885,6 @@ struct file *open_exec(const char *name) · 884 unmodified lines
885885 }
886886 EXPORT_SYMBOL(open_exec);
887887
888−int kernel_read(struct file *file, loff_t offset,
889− char *addr, unsigned long count)
890−{
891− mm_segment_t old_fs;
892− loff_t pos = offset;
893− int result;
894−
895− old_fs = get_fs();
896− set_fs(get_ds());
897− /* The cast to a user pointer is valid due to the set_fs() */
898− result = vfs_read(file, (void __user *)addr, count, &pos);
899− set_fs(old_fs);
900− return result;
901−}
902−
903−EXPORT_SYMBOL(kernel_read);
904−
905888 int kernel_read_file(struct file *file, void **buf, loff_t *size,
906889 loff_t max_size, enum kernel_read_file_id id)
907890 {
@@ -939,8 +922,7 @@ int kernel_read_file(struct file *file, void **buf, loff_t *size, · 31 unmodified lines
939922
940923 pos = 0;
941924 while (pos < i_size) {
942− bytes = kernel_read(file, pos, (char *)(*buf) + pos,
943− i_size - pos);
925+ bytes = kernel_read(file, *buf + pos, i_size - pos, &pos);
944926 if (bytes < 0) {
945927 ret = bytes;
946928 goto out;
@@ -948,7 +930,6 @@ int kernel_read_file(struct file *file, void **buf, loff_t *size, · 1 unmodified line
948930
949931 if (bytes == 0)
950932 break;
951− pos += bytes;
952933 }
953934
954935 if (pos != i_size) {
@@ -1567,6 +1548,7 @@ static void bprm_fill_uid(struct linux_binprm *bprm) · 612 unmodified lines
15671548 int prepare_binprm(struct linux_binprm *bprm)
15681549 {
15691550 int retval;
1551+ loff_t pos = 0;
15701552
15711553 bprm_fill_uid(bprm);
15721554
@@ -1577,7 +1559,7 @@ int prepare_binprm(struct linux_binprm *bprm) · 4 unmodified lines
15771559 bprm->called_set_creds = 1;
15781560
15791561 memset(bprm->buf, 0, BINPRM_BUF_SIZE);
1580− return kernel_read(bprm->file, 0, bprm->buf, BINPRM_BUF_SIZE);
1562+ return kernel_read(bprm->file, bprm->buf, BINPRM_BUF_SIZE, &pos);
15811563 }
15821564
15831565 EXPORT_SYMBOL(prepare_binprm);
fs/read_write.c+32−11
@@ -413,7 +413,20 @@ ssize_t __vfs_read(struct file *file, char __user *buf, size_t count, · 412 unmodified lines
413413 else
414414 return -EINVAL;
415415 }
416−EXPORT_SYMBOL(__vfs_read);
416+
417+ssize_t kernel_read(struct file *file, void *buf, size_t count, loff_t *pos)
418+{
419+ mm_segment_t old_fs;
420+ ssize_t result;
421+
422+ old_fs = get_fs();
423+ set_fs(get_ds());
424+ /* The cast to a user pointer is valid due to the set_fs() */
425+ result = vfs_read(file, (void __user *)buf, count, pos);
426+ set_fs(old_fs);
427+ return result;
428+}
429+EXPORT_SYMBOL(kernel_read);
417430
418431 ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos)
419432 {
@@ -441,8 +454,6 @@ ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos) · 21 unmodified lines
441454 return ret;
442455 }
443456
444−EXPORT_SYMBOL(vfs_read);
445−
446457 static ssize_t new_sync_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos)
447458 {
448459 struct iovec iov = { .iov_base = (void __user *)buf, .iov_len = len };
@@ -471,9 +482,8 @@ ssize_t __vfs_write(struct file *file, const char __user *p, size_t count, · 22 unmodified lines
471482 else
472483 return -EINVAL;
473484 }
474−EXPORT_SYMBOL(__vfs_write);
475485
476−ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t *pos)
486+ssize_t __kernel_write(struct file *file, const void *buf, size_t count, loff_t *pos)
477487 {
478488 mm_segment_t old_fs;
479489 const char __user *p;
@@ -496,9 +506,24 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t · 16 unmodified lines
496506 inc_syscw(current);
497507 return ret;
498508 }
499−
500509 EXPORT_SYMBOL(__kernel_write);
501510
511+ssize_t kernel_write(struct file *file, const void *buf, size_t count,
512+ loff_t *pos)
513+{
514+ mm_segment_t old_fs;
515+ ssize_t res;
516+
517+ old_fs = get_fs();
518+ set_fs(get_ds());
519+ /* The cast to a user pointer is valid due to the set_fs() */
520+ res = vfs_write(file, (__force const char __user *)buf, count, pos);
521+ set_fs(old_fs);
522+
523+ return res;
524+}
525+EXPORT_SYMBOL(kernel_write);
526+
502527 ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_t *pos)
503528 {
504529 ssize_t ret;
@@ -527,8 +552,6 @@ ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_ · 22 unmodified lines
527552 return ret;
528553 }
529554
530−EXPORT_SYMBOL(vfs_write);
531−
532555 static inline loff_t file_pos_read(struct file *file)
533556 {
534557 return file->f_pos;
@@ -959,9 +982,8 @@ ssize_t vfs_readv(struct file *file, const struct iovec __user *vec, · 424 unmodified lines
959982
960983 return ret;
961984 }
962−EXPORT_SYMBOL(vfs_readv);
963985
964−ssize_t vfs_writev(struct file *file, const struct iovec __user *vec,
986+static ssize_t vfs_writev(struct file *file, const struct iovec __user *vec,
965987 unsigned long vlen, loff_t *pos, rwf_t flags)
966988 {
967989 struct iovec iovstack[UIO_FASTIOV];
@@ -978,7 +1000,6 @@ ssize_t vfs_writev(struct file *file, const struct iovec __user *vec, · 10 unmodified lines
9781000 }
9791001 return ret;
9801002 }
981−EXPORT_SYMBOL(vfs_writev);
9821003
9831004 static ssize_t do_readv(unsigned long fd, const struct iovec __user *vec,
9841005 unsigned long vlen, rwf_t flags)
fs/splice.c+0−16
@@ -364,22 +364,6 @@ static ssize_t kernel_readv(struct file *file, const struct kvec *vec, · 363 unmodified lines
364364 return res;
365365 }
366366
367−ssize_t kernel_write(struct file *file, const char *buf, size_t count,
368− loff_t pos)
369−{
370− mm_segment_t old_fs;
371− ssize_t res;
372−
373− old_fs = get_fs();
374− set_fs(get_ds());
375− /* The cast to a user pointer is valid due to the set_fs() */
376− res = vfs_write(file, (__force const char __user *)buf, count, &pos);
377− set_fs(old_fs);
378−
379− return res;
380−}
381−EXPORT_SYMBOL(kernel_write);
382−
383367 static ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
384368 struct pipe_inode_info *pipe, size_t len,
385369 unsigned int flags)
include/linux/fs.h+3−6
@@ -1754,13 +1754,10 @@ ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector, · 1753 unmodified lines
17541754 struct iovec **ret_pointer);
17551755
17561756 extern ssize_t __vfs_read(struct file *, char __user *, size_t, loff_t *);
1757−extern ssize_t __vfs_write(struct file *, const char __user *, size_t, loff_t *);
17581757 extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *);
17591758 extern ssize_t vfs_write(struct file *, const char __user *, size_t, loff_t *);
17601759 extern ssize_t vfs_readv(struct file *, const struct iovec __user *,
17611760 unsigned long, loff_t *, rwf_t);
1762−extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
1763− unsigned long, loff_t *, rwf_t);
17641761 extern ssize_t vfs_copy_file_range(struct file *, loff_t , struct file *,
17651762 loff_t, size_t, unsigned int);
17661763 extern int vfs_clone_file_prep_inodes(struct inode *inode_in, loff_t pos_in,
@@ -2788,15 +2785,15 @@ static inline const char *kernel_read_file_id_str(enum kernel_read_file_id id) · 1021 unmodified lines
27882785 return kernel_read_file_str[id];
27892786 }
27902787
2791−extern int kernel_read(struct file *, loff_t, char *, unsigned long);
27922788 extern int kernel_read_file(struct file *, void **, loff_t *, loff_t,
27932789 enum kernel_read_file_id);
27942790 extern int kernel_read_file_from_path(char *, void **, loff_t *, loff_t,
27952791 enum kernel_read_file_id);
27962792 extern int kernel_read_file_from_fd(int, void **, loff_t *, loff_t,
27972793 enum kernel_read_file_id);
2798−extern ssize_t kernel_write(struct file *, const char *, size_t, loff_t);
2799−extern ssize_t __kernel_write(struct file *, const char *, size_t, loff_t *);
2794+extern ssize_t kernel_read(struct file *, void *, size_t, loff_t *);
2795+extern ssize_t kernel_write(struct file *, const void *, size_t, loff_t *);
2796+extern ssize_t __kernel_write(struct file *, const void *, size_t, loff_t *);
28002797 extern struct file * open_exec(const char *);
28012798
28022799 /* fs/dcache.c -- generic fs support functions */
kernel/acct.c+1−1
@@ -516,7 +516,7 @@ static void do_acct_process(struct bsd_acct_struct *acct) · 515 unmodified lines
516516 if (file_start_write_trylock(file)) {
517517 /* it's been opened O_APPEND, so position is irrelevant */
518518 loff_t pos = 0;
519− __kernel_write(file, (char *)&ac, sizeof(acct_t), &pos);
519+ __kernel_write(file, &ac, sizeof(acct_t), &pos);
520520 file_end_write(file);
521521 }
522522 out:
kernel/sysctl_binary.c+14−7
@@ -986,8 +986,9 @@ static ssize_t bin_intvec(struct file *file, · 985 unmodified lines
986986 size_t length = oldlen / sizeof(*vec);
987987 char *str, *end;
988988 int i;
989+ loff_t pos = 0;
989990
990− result = kernel_read(file, 0, buffer, BUFSZ - 1);
991+ result = kernel_read(file, buffer, BUFSZ - 1, &pos);
991992 if (result < 0)
992993 goto out_kfree;
993994
@@ -1016,6 +1017,7 @@ static ssize_t bin_intvec(struct file *file, · 22 unmodified lines
10161017 size_t length = newlen / sizeof(*vec);
10171018 char *str, *end;
10181019 int i;
1020+ loff_t pos = 0;
10191021
10201022 str = buffer;
10211023 end = str + BUFSZ;
@@ -1029,7 +1031,7 @@ static ssize_t bin_intvec(struct file *file, · 7 unmodified lines
10291031 str += scnprintf(str, end - str, "%lu\t", value);
10301032 }
10311033
1032− result = kernel_write(file, buffer, str - buffer, 0);
1034+ result = kernel_write(file, buffer, str - buffer, &pos);
10331035 if (result < 0)
10341036 goto out_kfree;
10351037 }
@@ -1057,8 +1059,9 @@ static ssize_t bin_ulongvec(struct file *file, · 21 unmodified lines
10571059 size_t length = oldlen / sizeof(*vec);
10581060 char *str, *end;
10591061 int i;
1062+ loff_t pos = 0;
10601063
1061− result = kernel_read(file, 0, buffer, BUFSZ - 1);
1064+ result = kernel_read(file, buffer, BUFSZ - 1, &pos);
10621065 if (result < 0)
10631066 goto out_kfree;
10641067
@@ -1087,6 +1090,7 @@ static ssize_t bin_ulongvec(struct file *file, · 22 unmodified lines
10871090 size_t length = newlen / sizeof(*vec);
10881091 char *str, *end;
10891092 int i;
1093+ loff_t pos = 0;
10901094
10911095 str = buffer;
10921096 end = str + BUFSZ;
@@ -1100,7 +1104,7 @@ static ssize_t bin_ulongvec(struct file *file, · 7 unmodified lines
11001104 str += scnprintf(str, end - str, "%lu\t", value);
11011105 }
11021106
1103− result = kernel_write(file, buffer, str - buffer, 0);
1107+ result = kernel_write(file, buffer, str - buffer, &pos);
11041108 if (result < 0)
11051109 goto out_kfree;
11061110 }
@@ -1120,8 +1124,9 @@ static ssize_t bin_uuid(struct file *file, · 13 unmodified lines
11201124 if (oldval && oldlen) {
11211125 char buf[UUID_STRING_LEN + 1];
11221126 uuid_t uuid;
1127+ loff_t pos = 0;
11231128
1124− result = kernel_read(file, 0, buf, sizeof(buf) - 1);
1129+ result = kernel_read(file, buf, sizeof(buf) - 1, &pos);
11251130 if (result < 0)
11261131 goto out;
11271132
@@ -1154,8 +1159,9 @@ static ssize_t bin_dn_node_address(struct file *file, · 26 unmodified lines
11541159 char buf[15], *nodep;
11551160 unsigned long area, node;
11561161 __le16 dnaddr;
1162+ loff_t pos = 0;
11571163
1158− result = kernel_read(file, 0, buf, sizeof(buf) - 1);
1164+ result = kernel_read(file, buf, sizeof(buf) - 1, &pos);
11591165 if (result < 0)
11601166 goto out;
11611167
@@ -1188,6 +1194,7 @@ static ssize_t bin_dn_node_address(struct file *file, · 26 unmodified lines
11881194 __le16 dnaddr;
11891195 char buf[15];
11901196 int len;
1197+ loff_t pos = 0;
11911198
11921199 result = -EINVAL;
11931200 if (newlen != sizeof(dnaddr))
@@ -1201,7 +1208,7 @@ static ssize_t bin_dn_node_address(struct file *file, · 7 unmodified lines
12011208 le16_to_cpu(dnaddr) >> 10,
12021209 le16_to_cpu(dnaddr) & 0x3ff);
12031210
1204− result = kernel_write(file, buf, len, 0);
1211+ result = kernel_write(file, buf, len, &pos);
12051212 if (result < 0)
12061213 goto out;
12071214 }
mm/nommu.c+1−6
@@ -1164,17 +1164,12 @@ static int do_mmap_private(struct vm_area_struct *vma, · 1163 unmodified lines
11641164
11651165 if (vma->vm_file) {
11661166 /* read the contents of a file into the copy */
1167− mm_segment_t old_fs;
11681167 loff_t fpos;
11691168
11701169 fpos = vma->vm_pgoff;
11711170 fpos <<= PAGE_SHIFT;
11721171
1173− old_fs = get_fs();
1174− set_fs(KERNEL_DS);
1175− ret = __vfs_read(vma->vm_file, base, len, &fpos);
1176− set_fs(old_fs);
1177−
1172+ ret = kernel_read(vma->vm_file, base, len, &fpos);
11781173 if (ret < 0)
11791174 goto error_free;
11801175
net/9p/trans_fd.c+5−9
@@ -272,6 +272,7 @@ static int p9_fd_read(struct p9_client *client, void *v, int len) · 271 unmodified lines
272272 {
273273 int ret;
274274 struct p9_trans_fd *ts = NULL;
275+ loff_t pos;
275276
276277 if (client && client->status != Disconnected)
277278 ts = client->trans;
@@ -282,7 +283,8 @@ static int p9_fd_read(struct p9_client *client, void *v, int len) · 4 unmodified lines
282283 if (!(ts->rd->f_flags & O_NONBLOCK))
283284 p9_debug(P9_DEBUG_ERROR, "blocking read ...\n");
284285
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);
286288 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
287289 client->status = Disconnected;
288290 return ret;
@@ -420,8 +422,7 @@ error: · 131 unmodified lines
420422
421423 static int p9_fd_write(struct p9_client *client, void *v, int len)
422424 {
423− int ret;
424− mm_segment_t oldfs;
425+ ssize_t ret;
425426 struct p9_trans_fd *ts = NULL;
426427
427428 if (client && client->status != Disconnected)
@@ -433,12 +434,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len) · 5 unmodified lines
433434 if (!(ts->wr->f_flags & O_NONBLOCK))
434435 p9_debug(P9_DEBUG_ERROR, "blocking write ...\n");
435436
436− oldfs = get_fs();
437− set_fs(get_ds());
438− /* The cast to a user pointer is valid due to the set_fs() */
439− ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
440− set_fs(oldfs);
441−
437+ ret = kernel_write(ts->wr, v, len, &ts->wr->f_pos);
442438 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
443439 client->status = Disconnected;
444440 return ret;
security/keys/big_key.c+4−2
@@ -147,6 +147,7 @@ int big_key_preparse(struct key_preparsed_payload *prep) · 146 unmodified lines
147147 * File content is stored encrypted with randomly generated key.
148148 */
149149 size_t enclen = ALIGN(datalen, crypto_skcipher_blocksize(big_key_skcipher));
150+ loff_t pos = 0;
150151
151152 /* prepare aligned data to encrypt */
152153 data = kmalloc(enclen, GFP_KERNEL);
@@ -179,7 +180,7 @@ int big_key_preparse(struct key_preparsed_payload *prep) · 26 unmodified lines
179180 goto err_enckey;
180181 }
181182
182− written = kernel_write(file, data, enclen, 0);
183+ written = kernel_write(file, data, enclen, &pos);
183184 if (written != enclen) {
184185 ret = written;
185186 if (written >= 0)
@@ -295,6 +296,7 @@ long big_key_read(const struct key *key, char __user *buffer, size_t buflen) · 109 unmodified lines
295296 u8 *data;
296297 u8 *enckey = (u8 *)key->payload.data[big_key_data];
297298 size_t enclen = ALIGN(datalen, crypto_skcipher_blocksize(big_key_skcipher));
299+ loff_t pos = 0;
298300
299301 data = kmalloc(enclen, GFP_KERNEL);
300302 if (!data)
@@ -307,7 +309,7 @@ long big_key_read(const struct key *key, char __user *buffer, size_t buflen) · 6 unmodified lines
307309 }
308310
309311 /* read file to kernel and decrypt */
310− ret = kernel_read(file, 0, data, enclen);
312+ ret = kernel_read(file, data, enclen, &pos);
311313 if (ret >= 0 && ret != enclen) {
312314 ret = -EIO;
313315 goto err_fput;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t