Commit 5790642b authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David S. Miller

net: switch sock_setbindtodevice to sockptr_t

Pass a sockptr_t to prepare for set_fs-less handling of the kernel
pointer from bpf-cgroup.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b1ea9ff6
...@@ -609,8 +609,7 @@ int sock_bindtoindex(struct sock *sk, int ifindex, bool lock_sk) ...@@ -609,8 +609,7 @@ int sock_bindtoindex(struct sock *sk, int ifindex, bool lock_sk)
} }
EXPORT_SYMBOL(sock_bindtoindex); EXPORT_SYMBOL(sock_bindtoindex);
static int sock_setbindtodevice(struct sock *sk, char __user *optval, static int sock_setbindtodevice(struct sock *sk, sockptr_t optval, int optlen)
int optlen)
{ {
int ret = -ENOPROTOOPT; int ret = -ENOPROTOOPT;
#ifdef CONFIG_NETDEVICES #ifdef CONFIG_NETDEVICES
...@@ -632,7 +631,7 @@ static int sock_setbindtodevice(struct sock *sk, char __user *optval, ...@@ -632,7 +631,7 @@ static int sock_setbindtodevice(struct sock *sk, char __user *optval,
memset(devname, 0, sizeof(devname)); memset(devname, 0, sizeof(devname));
ret = -EFAULT; ret = -EFAULT;
if (copy_from_user(devname, optval, optlen)) if (copy_from_sockptr(devname, optval, optlen))
goto out; goto out;
index = 0; index = 0;
...@@ -840,7 +839,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname, ...@@ -840,7 +839,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
*/ */
if (optname == SO_BINDTODEVICE) if (optname == SO_BINDTODEVICE)
return sock_setbindtodevice(sk, optval, optlen); return sock_setbindtodevice(sk, USER_SOCKPTR(optval), optlen);
if (optlen < sizeof(int)) if (optlen < sizeof(int))
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment