mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-20 13:41:30 +00:00
{compat_,}verify_iovec(): switch to generic copying of iovecs
use {compat_,}rw_copy_check_uvector(). As the result, we are guaranteed that all iovecs seen in ->msg_iov by ->sendmsg() and ->recvmsg() will pass access_ok(). Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
666547ff59
commit
0844932009
3 changed files with 36 additions and 88 deletions
38
net/socket.c
38
net/socket.c
|
@ -2032,24 +2032,14 @@ static int ___sys_sendmsg(struct socket *sock, struct user_msghdr __user *msg,
|
|||
return err;
|
||||
}
|
||||
|
||||
if (msg_sys->msg_iovlen > UIO_FASTIOV) {
|
||||
err = -EMSGSIZE;
|
||||
if (msg_sys->msg_iovlen > UIO_MAXIOV)
|
||||
goto out;
|
||||
err = -ENOMEM;
|
||||
iov = kmalloc(msg_sys->msg_iovlen * sizeof(struct iovec),
|
||||
GFP_KERNEL);
|
||||
if (!iov)
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* This will also move the address data into kernel space */
|
||||
if (MSG_CMSG_COMPAT & flags) {
|
||||
err = verify_compat_iovec(msg_sys, iov, &address, VERIFY_READ);
|
||||
} else
|
||||
err = verify_iovec(msg_sys, iov, &address, VERIFY_READ);
|
||||
if (MSG_CMSG_COMPAT & flags)
|
||||
err = verify_compat_iovec(msg_sys, iovstack, &address, WRITE);
|
||||
else
|
||||
err = verify_iovec(msg_sys, iovstack, &address, WRITE);
|
||||
if (err < 0)
|
||||
goto out_freeiov;
|
||||
iov = msg_sys->msg_iov;
|
||||
total_len = err;
|
||||
|
||||
err = -ENOBUFS;
|
||||
|
@ -2118,7 +2108,6 @@ out_freectl:
|
|||
out_freeiov:
|
||||
if (iov != iovstack)
|
||||
kfree(iov);
|
||||
out:
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -2244,28 +2233,18 @@ static int ___sys_recvmsg(struct socket *sock, struct user_msghdr __user *msg,
|
|||
return err;
|
||||
}
|
||||
|
||||
if (msg_sys->msg_iovlen > UIO_FASTIOV) {
|
||||
err = -EMSGSIZE;
|
||||
if (msg_sys->msg_iovlen > UIO_MAXIOV)
|
||||
goto out;
|
||||
err = -ENOMEM;
|
||||
iov = kmalloc(msg_sys->msg_iovlen * sizeof(struct iovec),
|
||||
GFP_KERNEL);
|
||||
if (!iov)
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Save the user-mode address (verify_iovec will change the
|
||||
* kernel msghdr to use the kernel address space)
|
||||
*/
|
||||
uaddr = (__force void __user *)msg_sys->msg_name;
|
||||
uaddr_len = COMPAT_NAMELEN(msg);
|
||||
if (MSG_CMSG_COMPAT & flags)
|
||||
err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
|
||||
err = verify_compat_iovec(msg_sys, iovstack, &addr, READ);
|
||||
else
|
||||
err = verify_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
|
||||
err = verify_iovec(msg_sys, iovstack, &addr, READ);
|
||||
if (err < 0)
|
||||
goto out_freeiov;
|
||||
iov = msg_sys->msg_iov;
|
||||
total_len = err;
|
||||
|
||||
cmsg_ptr = (unsigned long)msg_sys->msg_control;
|
||||
|
@ -2306,7 +2285,6 @@ static int ___sys_recvmsg(struct socket *sock, struct user_msghdr __user *msg,
|
|||
out_freeiov:
|
||||
if (iov != iovstack)
|
||||
kfree(iov);
|
||||
out:
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue