aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/read_write.c24
-rw-r--r--include/linux/fs.h1
-rw-r--r--security/integrity/iint.c10
3 files changed, 22 insertions, 13 deletions
diff --git a/fs/read_write.c b/fs/read_write.c
index 009d8542a889..f45b2ae5d5f1 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -412,6 +412,23 @@ ssize_t new_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *p
412 412
413EXPORT_SYMBOL(new_sync_read); 413EXPORT_SYMBOL(new_sync_read);
414 414
415ssize_t __vfs_read(struct file *file, char __user *buf, size_t count,
416 loff_t *pos)
417{
418 ssize_t ret;
419
420 if (file->f_op->read)
421 ret = file->f_op->read(file, buf, count, pos);
422 else if (file->f_op->aio_read)
423 ret = do_sync_read(file, buf, count, pos);
424 else if (file->f_op->read_iter)
425 ret = new_sync_read(file, buf, count, pos);
426 else
427 ret = -EINVAL;
428
429 return ret;
430}
431
415ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos) 432ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos)
416{ 433{
417 ssize_t ret; 434 ssize_t ret;
@@ -426,12 +443,7 @@ ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos)
426 ret = rw_verify_area(READ, file, pos, count); 443 ret = rw_verify_area(READ, file, pos, count);
427 if (ret >= 0) { 444 if (ret >= 0) {
428 count = ret; 445 count = ret;
429 if (file->f_op->read) 446 ret = __vfs_read(file, buf, count, pos);
430 ret = file->f_op->read(file, buf, count, pos);
431 else if (file->f_op->aio_read)
432 ret = do_sync_read(file, buf, count, pos);
433 else
434 ret = new_sync_read(file, buf, count, pos);
435 if (ret > 0) { 447 if (ret > 0) {
436 fsnotify_access(file); 448 fsnotify_access(file);
437 add_rchar(current, ret); 449 add_rchar(current, ret);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index e11d60cc867b..ac3a36e05da9 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1527,6 +1527,7 @@ ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector,
1527 struct iovec *fast_pointer, 1527 struct iovec *fast_pointer,
1528 struct iovec **ret_pointer); 1528 struct iovec **ret_pointer);
1529 1529
1530extern ssize_t __vfs_read(struct file *, char __user *, size_t, loff_t *);
1530extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *); 1531extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *);
1531extern ssize_t vfs_write(struct file *, const char __user *, size_t, loff_t *); 1532extern ssize_t vfs_write(struct file *, const char __user *, size_t, loff_t *);
1532extern ssize_t vfs_readv(struct file *, const struct iovec __user *, 1533extern ssize_t vfs_readv(struct file *, const struct iovec __user *,
diff --git a/security/integrity/iint.c b/security/integrity/iint.c
index df45640fbac6..dbb6d141c3db 100644
--- a/security/integrity/iint.c
+++ b/security/integrity/iint.c
@@ -184,20 +184,16 @@ int integrity_kernel_read(struct file *file, loff_t offset,
184{ 184{
185 mm_segment_t old_fs; 185 mm_segment_t old_fs;
186 char __user *buf = (char __user *)addr; 186 char __user *buf = (char __user *)addr;
187 ssize_t ret = -EINVAL; 187 ssize_t ret;
188 188
189 if (!(file->f_mode & FMODE_READ)) 189 if (!(file->f_mode & FMODE_READ))
190 return -EBADF; 190 return -EBADF;
191 191
192 old_fs = get_fs(); 192 old_fs = get_fs();
193 set_fs(get_ds()); 193 set_fs(get_ds());
194 if (file->f_op->read) 194 ret = __vfs_read(file, buf, count, &offset);
195 ret = file->f_op->read(file, buf, count, &offset);
196 else if (file->f_op->aio_read)
197 ret = do_sync_read(file, buf, count, &offset);
198 else if (file->f_op->read_iter)
199 ret = new_sync_read(file, buf, count, &offset);
200 set_fs(old_fs); 195 set_fs(old_fs);
196
201 return ret; 197 return ret;
202} 198}
203 199