Commit 01ccb5b4 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David S. Miller

net/ipv4: switch ip_mroute_setsockopt 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 b03afaa8
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <net/fib_notifier.h> #include <net/fib_notifier.h>
#include <uapi/linux/mroute.h> #include <uapi/linux/mroute.h>
#include <linux/mroute_base.h> #include <linux/mroute_base.h>
#include <linux/sockptr.h>
#ifdef CONFIG_IP_MROUTE #ifdef CONFIG_IP_MROUTE
static inline int ip_mroute_opt(int opt) static inline int ip_mroute_opt(int opt)
...@@ -15,7 +16,7 @@ static inline int ip_mroute_opt(int opt) ...@@ -15,7 +16,7 @@ static inline int ip_mroute_opt(int opt)
return opt >= MRT_BASE && opt <= MRT_MAX; return opt >= MRT_BASE && opt <= MRT_MAX;
} }
int ip_mroute_setsockopt(struct sock *, int, char __user *, unsigned int); int ip_mroute_setsockopt(struct sock *, int, sockptr_t, unsigned int);
int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *); int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg); int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg);
int ipmr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg); int ipmr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
...@@ -23,7 +24,7 @@ int ip_mr_init(void); ...@@ -23,7 +24,7 @@ int ip_mr_init(void);
bool ipmr_rule_default(const struct fib_rule *rule); bool ipmr_rule_default(const struct fib_rule *rule);
#else #else
static inline int ip_mroute_setsockopt(struct sock *sock, int optname, static inline int ip_mroute_setsockopt(struct sock *sock, int optname,
char __user *optval, unsigned int optlen) sockptr_t optval, unsigned int optlen)
{ {
return -ENOPROTOOPT; return -ENOPROTOOPT;
} }
......
...@@ -925,7 +925,8 @@ static int do_ip_setsockopt(struct sock *sk, int level, ...@@ -925,7 +925,8 @@ static int do_ip_setsockopt(struct sock *sk, int level,
if (optname == IP_ROUTER_ALERT) if (optname == IP_ROUTER_ALERT)
return ip_ra_control(sk, val ? 1 : 0, NULL); return ip_ra_control(sk, val ? 1 : 0, NULL);
if (ip_mroute_opt(optname)) if (ip_mroute_opt(optname))
return ip_mroute_setsockopt(sk, optname, optval, optlen); return ip_mroute_setsockopt(sk, optname, USER_SOCKPTR(optval),
optlen);
err = 0; err = 0;
if (needs_rtnl) if (needs_rtnl)
......
...@@ -1341,7 +1341,7 @@ static void mrtsock_destruct(struct sock *sk) ...@@ -1341,7 +1341,7 @@ static void mrtsock_destruct(struct sock *sk)
* MOSPF/PIM router set up we can clean this up. * MOSPF/PIM router set up we can clean this up.
*/ */
int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, int ip_mroute_setsockopt(struct sock *sk, int optname, sockptr_t optval,
unsigned int optlen) unsigned int optlen)
{ {
struct net *net = sock_net(sk); struct net *net = sock_net(sk);
...@@ -1413,7 +1413,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, ...@@ -1413,7 +1413,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval,
ret = -EINVAL; ret = -EINVAL;
break; break;
} }
if (copy_from_user(&vif, optval, sizeof(vif))) { if (copy_from_sockptr(&vif, optval, sizeof(vif))) {
ret = -EFAULT; ret = -EFAULT;
break; break;
} }
...@@ -1441,7 +1441,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, ...@@ -1441,7 +1441,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval,
ret = -EINVAL; ret = -EINVAL;
break; break;
} }
if (copy_from_user(&mfc, optval, sizeof(mfc))) { if (copy_from_sockptr(&val, optval, sizeof(val))) {
ret = -EFAULT; ret = -EFAULT;
break; break;
} }
...@@ -1459,7 +1459,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, ...@@ -1459,7 +1459,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval,
ret = -EINVAL; ret = -EINVAL;
break; break;
} }
if (get_user(val, (int __user *)optval)) { if (copy_from_sockptr(&val, optval, sizeof(val))) {
ret = -EFAULT; ret = -EFAULT;
break; break;
} }
...@@ -1471,7 +1471,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, ...@@ -1471,7 +1471,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval,
ret = -EINVAL; ret = -EINVAL;
break; break;
} }
if (get_user(val, (int __user *)optval)) { if (copy_from_sockptr(&val, optval, sizeof(val))) {
ret = -EFAULT; ret = -EFAULT;
break; break;
} }
...@@ -1486,7 +1486,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, ...@@ -1486,7 +1486,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval,
ret = -EINVAL; ret = -EINVAL;
break; break;
} }
if (get_user(val, (int __user *)optval)) { if (copy_from_sockptr(&val, optval, sizeof(val))) {
ret = -EFAULT; ret = -EFAULT;
break; break;
} }
...@@ -1508,7 +1508,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, ...@@ -1508,7 +1508,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval,
ret = -EINVAL; ret = -EINVAL;
break; break;
} }
if (get_user(uval, (u32 __user *)optval)) { if (copy_from_sockptr(&uval, optval, sizeof(uval))) {
ret = -EFAULT; ret = -EFAULT;
break; break;
} }
......
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