Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 309775
b: refs/heads/master
c: ac34ebb
h: refs/heads/master
i:
  309773: 7e88c89
  309771: 2070135
  309767: ae2963e
  309759: f82b8e1
v: v3
  • Loading branch information
Christopher Yeoh authored and Linus Torvalds committed Jun 1, 2012
1 parent cbcbb82 commit c34005c
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 24 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ee62c6b2dc93c09585b51fad18449dc5edb9977f
refs/heads/master: ac34ebb3a67e699edcb5ac72f19d31679369dfaa
4 changes: 2 additions & 2 deletions trunk/fs/aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1446,13 +1446,13 @@ static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
ret = compat_rw_copy_check_uvector(type,
(struct compat_iovec __user *)kiocb->ki_buf,
kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
&kiocb->ki_iovec, 1);
&kiocb->ki_iovec);
else
#endif
ret = rw_copy_check_uvector(type,
(struct iovec __user *)kiocb->ki_buf,
kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
&kiocb->ki_iovec, 1);
&kiocb->ki_iovec);
if (ret < 0)
goto out;

Expand Down
6 changes: 3 additions & 3 deletions trunk/fs/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ compat_sys_io_getevents(aio_context_t ctx_id,
ssize_t compat_rw_copy_check_uvector(int type,
const struct compat_iovec __user *uvector, unsigned long nr_segs,
unsigned long fast_segs, struct iovec *fast_pointer,
struct iovec **ret_pointer, int check_access)
struct iovec **ret_pointer)
{
compat_ssize_t tot_len;
struct iovec *iov = *ret_pointer = fast_pointer;
Expand Down Expand Up @@ -579,7 +579,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
}
if (len < 0) /* size_t not fitting in compat_ssize_t .. */
goto out;
if (check_access &&
if (type >= 0 &&
!access_ok(vrfy_dir(type), compat_ptr(buf), len)) {
ret = -EFAULT;
goto out;
Expand Down Expand Up @@ -1094,7 +1094,7 @@ static ssize_t compat_do_readv_writev(int type, struct file *file,
goto out;

tot_len = compat_rw_copy_check_uvector(type, uvector, nr_segs,
UIO_FASTIOV, iovstack, &iov, 1);
UIO_FASTIOV, iovstack, &iov);
if (tot_len == 0) {
ret = 0;
goto out;
Expand Down
7 changes: 3 additions & 4 deletions trunk/fs/read_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -633,8 +633,7 @@ ssize_t do_loop_readv_writev(struct file *filp, struct iovec *iov,
ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector,
unsigned long nr_segs, unsigned long fast_segs,
struct iovec *fast_pointer,
struct iovec **ret_pointer,
int check_access)
struct iovec **ret_pointer)
{
unsigned long seg;
ssize_t ret;
Expand Down Expand Up @@ -690,7 +689,7 @@ ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector,
ret = -EINVAL;
goto out;
}
if (check_access
if (type >= 0
&& unlikely(!access_ok(vrfy_dir(type), buf, len))) {
ret = -EFAULT;
goto out;
Expand Down Expand Up @@ -723,7 +722,7 @@ static ssize_t do_readv_writev(int type, struct file *file,
}

ret = rw_copy_check_uvector(type, uvector, nr_segs,
ARRAY_SIZE(iovstack), iovstack, &iov, 1);
ARRAY_SIZE(iovstack), iovstack, &iov);
if (ret <= 0)
goto out;

Expand Down
3 changes: 1 addition & 2 deletions trunk/include/linux/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,7 @@ extern ssize_t compat_rw_copy_check_uvector(int type,
const struct compat_iovec __user *uvector,
unsigned long nr_segs,
unsigned long fast_segs, struct iovec *fast_pointer,
struct iovec **ret_pointer,
int check_access);
struct iovec **ret_pointer);

extern void __user *compat_alloc_user_space(unsigned long len);

Expand Down
12 changes: 10 additions & 2 deletions trunk/include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,15 @@ struct inodes_stat_t {
#define WRITE_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FUA)
#define WRITE_FLUSH_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FLUSH | REQ_FUA)


/*
* Flag for rw_copy_check_uvector and compat_rw_copy_check_uvector
* that indicates that they should check the contents of the iovec are
* valid, but not check the memory that the iovec elements
* points too.
*/
#define CHECK_IOVEC_ONLY -1

#define SEL_IN 1
#define SEL_OUT 2
#define SEL_EX 4
Expand Down Expand Up @@ -1690,8 +1699,7 @@ struct seq_file;
ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector,
unsigned long nr_segs, unsigned long fast_segs,
struct iovec *fast_pointer,
struct iovec **ret_pointer,
int check_access);
struct iovec **ret_pointer);

extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *);
extern ssize_t vfs_write(struct file *, const char __user *, size_t, loff_t *);
Expand Down
16 changes: 8 additions & 8 deletions trunk/mm/process_vm_access.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,15 +371,15 @@ static ssize_t process_vm_rw(pid_t pid,
/* Check iovecs */
if (vm_write)
rc = rw_copy_check_uvector(WRITE, lvec, liovcnt, UIO_FASTIOV,
iovstack_l, &iov_l, 1);
iovstack_l, &iov_l);
else
rc = rw_copy_check_uvector(READ, lvec, liovcnt, UIO_FASTIOV,
iovstack_l, &iov_l, 1);
iovstack_l, &iov_l);
if (rc <= 0)
goto free_iovecs;

rc = rw_copy_check_uvector(READ, rvec, riovcnt, UIO_FASTIOV,
iovstack_r, &iov_r, 0);
rc = rw_copy_check_uvector(CHECK_IOVEC_ONLY, rvec, riovcnt, UIO_FASTIOV,
iovstack_r, &iov_r);
if (rc <= 0)
goto free_iovecs;

Expand Down Expand Up @@ -438,16 +438,16 @@ compat_process_vm_rw(compat_pid_t pid,
if (vm_write)
rc = compat_rw_copy_check_uvector(WRITE, lvec, liovcnt,
UIO_FASTIOV, iovstack_l,
&iov_l, 1);
&iov_l);
else
rc = compat_rw_copy_check_uvector(READ, lvec, liovcnt,
UIO_FASTIOV, iovstack_l,
&iov_l, 1);
&iov_l);
if (rc <= 0)
goto free_iovecs;
rc = compat_rw_copy_check_uvector(READ, rvec, riovcnt,
rc = compat_rw_copy_check_uvector(CHECK_IOVEC_ONLY, rvec, riovcnt,
UIO_FASTIOV, iovstack_r,
&iov_r, 0);
&iov_r);
if (rc <= 0)
goto free_iovecs;

Expand Down
2 changes: 1 addition & 1 deletion trunk/security/keys/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ long compat_keyctl_instantiate_key_iov(

ret = compat_rw_copy_check_uvector(WRITE, _payload_iov, ioc,
ARRAY_SIZE(iovstack),
iovstack, &iov, 1);
iovstack, &iov);
if (ret < 0)
return ret;
if (ret == 0)
Expand Down
2 changes: 1 addition & 1 deletion trunk/security/keys/keyctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
goto no_payload;

ret = rw_copy_check_uvector(WRITE, _payload_iov, ioc,
ARRAY_SIZE(iovstack), iovstack, &iov, 1);
ARRAY_SIZE(iovstack), iovstack, &iov);
if (ret < 0)
return ret;
if (ret == 0)
Expand Down

0 comments on commit c34005c

Please sign in to comment.