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

netfilter: switch nf_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 ab214d1b
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/static_key.h> #include <linux/static_key.h>
#include <linux/netfilter_defs.h> #include <linux/netfilter_defs.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/sockptr.h>
#include <net/net_namespace.h> #include <net/net_namespace.h>
static inline int NF_DROP_GETERR(int verdict) static inline int NF_DROP_GETERR(int verdict)
...@@ -163,7 +164,8 @@ struct nf_sockopt_ops { ...@@ -163,7 +164,8 @@ struct nf_sockopt_ops {
/* Non-inclusive ranges: use 0/0/NULL to never get called. */ /* Non-inclusive ranges: use 0/0/NULL to never get called. */
int set_optmin; int set_optmin;
int set_optmax; int set_optmax;
int (*set)(struct sock *sk, int optval, void __user *user, unsigned int len); int (*set)(struct sock *sk, int optval, sockptr_t arg,
unsigned int len);
int get_optmin; int get_optmin;
int get_optmax; int get_optmax;
int (*get)(struct sock *sk, int optval, void __user *user, int *len); int (*get)(struct sock *sk, int optval, void __user *user, int *len);
...@@ -338,7 +340,7 @@ NF_HOOK_LIST(uint8_t pf, unsigned int hook, struct net *net, struct sock *sk, ...@@ -338,7 +340,7 @@ NF_HOOK_LIST(uint8_t pf, unsigned int hook, struct net *net, struct sock *sk,
} }
/* Call setsockopt() */ /* Call setsockopt() */
int nf_setsockopt(struct sock *sk, u_int8_t pf, int optval, char __user *opt, int nf_setsockopt(struct sock *sk, u_int8_t pf, int optval, sockptr_t opt,
unsigned int len); unsigned int len);
int nf_getsockopt(struct sock *sk, u_int8_t pf, int optval, char __user *opt, int nf_getsockopt(struct sock *sk, u_int8_t pf, int optval, char __user *opt,
int *len); int *len);
......
...@@ -1063,14 +1063,13 @@ static int do_replace_finish(struct net *net, struct ebt_replace *repl, ...@@ -1063,14 +1063,13 @@ static int do_replace_finish(struct net *net, struct ebt_replace *repl,
} }
/* replace the table */ /* replace the table */
static int do_replace(struct net *net, const void __user *user, static int do_replace(struct net *net, sockptr_t arg, unsigned int len)
unsigned int len)
{ {
int ret, countersize; int ret, countersize;
struct ebt_table_info *newinfo; struct ebt_table_info *newinfo;
struct ebt_replace tmp; struct ebt_replace tmp;
if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) if (copy_from_sockptr(&tmp, arg, sizeof(tmp)) != 0)
return -EFAULT; return -EFAULT;
if (len != sizeof(tmp) + tmp.entries_size) if (len != sizeof(tmp) + tmp.entries_size)
...@@ -1286,12 +1285,11 @@ static int do_update_counters(struct net *net, const char *name, ...@@ -1286,12 +1285,11 @@ static int do_update_counters(struct net *net, const char *name,
return ret; return ret;
} }
static int update_counters(struct net *net, const void __user *user, static int update_counters(struct net *net, sockptr_t arg, unsigned int len)
unsigned int len)
{ {
struct ebt_replace hlp; struct ebt_replace hlp;
if (copy_from_user(&hlp, user, sizeof(hlp))) if (copy_from_sockptr(&hlp, arg, sizeof(hlp)))
return -EFAULT; return -EFAULT;
if (len != sizeof(hlp) + hlp.num_counters * sizeof(struct ebt_counter)) if (len != sizeof(hlp) + hlp.num_counters * sizeof(struct ebt_counter))
...@@ -2079,7 +2077,7 @@ static int compat_copy_entries(unsigned char *data, unsigned int size_user, ...@@ -2079,7 +2077,7 @@ static int compat_copy_entries(unsigned char *data, unsigned int size_user,
static int compat_copy_ebt_replace_from_user(struct ebt_replace *repl, static int compat_copy_ebt_replace_from_user(struct ebt_replace *repl,
void __user *user, unsigned int len) sockptr_t arg, unsigned int len)
{ {
struct compat_ebt_replace tmp; struct compat_ebt_replace tmp;
int i; int i;
...@@ -2087,7 +2085,7 @@ static int compat_copy_ebt_replace_from_user(struct ebt_replace *repl, ...@@ -2087,7 +2085,7 @@ static int compat_copy_ebt_replace_from_user(struct ebt_replace *repl,
if (len < sizeof(tmp)) if (len < sizeof(tmp))
return -EINVAL; return -EINVAL;
if (copy_from_user(&tmp, user, sizeof(tmp))) if (copy_from_sockptr(&tmp, arg, sizeof(tmp)))
return -EFAULT; return -EFAULT;
if (len != sizeof(tmp) + tmp.entries_size) if (len != sizeof(tmp) + tmp.entries_size)
...@@ -2114,8 +2112,7 @@ static int compat_copy_ebt_replace_from_user(struct ebt_replace *repl, ...@@ -2114,8 +2112,7 @@ static int compat_copy_ebt_replace_from_user(struct ebt_replace *repl,
return 0; return 0;
} }
static int compat_do_replace(struct net *net, void __user *user, static int compat_do_replace(struct net *net, sockptr_t arg, unsigned int len)
unsigned int len)
{ {
int ret, i, countersize, size64; int ret, i, countersize, size64;
struct ebt_table_info *newinfo; struct ebt_table_info *newinfo;
...@@ -2123,10 +2120,10 @@ static int compat_do_replace(struct net *net, void __user *user, ...@@ -2123,10 +2120,10 @@ static int compat_do_replace(struct net *net, void __user *user,
struct ebt_entries_buf_state state; struct ebt_entries_buf_state state;
void *entries_tmp; void *entries_tmp;
ret = compat_copy_ebt_replace_from_user(&tmp, user, len); ret = compat_copy_ebt_replace_from_user(&tmp, arg, len);
if (ret) { if (ret) {
/* try real handler in case userland supplied needed padding */ /* try real handler in case userland supplied needed padding */
if (ret == -EINVAL && do_replace(net, user, len) == 0) if (ret == -EINVAL && do_replace(net, arg, len) == 0)
ret = 0; ret = 0;
return ret; return ret;
} }
...@@ -2217,17 +2214,17 @@ static int compat_do_replace(struct net *net, void __user *user, ...@@ -2217,17 +2214,17 @@ static int compat_do_replace(struct net *net, void __user *user,
goto free_entries; goto free_entries;
} }
static int compat_update_counters(struct net *net, void __user *user, static int compat_update_counters(struct net *net, sockptr_t arg,
unsigned int len) unsigned int len)
{ {
struct compat_ebt_replace hlp; struct compat_ebt_replace hlp;
if (copy_from_user(&hlp, user, sizeof(hlp))) if (copy_from_sockptr(&hlp, arg, sizeof(hlp)))
return -EFAULT; return -EFAULT;
/* try real handler in case userland supplied needed padding */ /* try real handler in case userland supplied needed padding */
if (len != sizeof(hlp) + hlp.num_counters * sizeof(struct ebt_counter)) if (len != sizeof(hlp) + hlp.num_counters * sizeof(struct ebt_counter))
return update_counters(net, user, len); return update_counters(net, arg, len);
return do_update_counters(net, hlp.name, compat_ptr(hlp.counters), return do_update_counters(net, hlp.name, compat_ptr(hlp.counters),
hlp.num_counters, len); hlp.num_counters, len);
...@@ -2368,7 +2365,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len) ...@@ -2368,7 +2365,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
return ret; return ret;
} }
static int do_ebt_set_ctl(struct sock *sk, int cmd, void __user *user, static int do_ebt_set_ctl(struct sock *sk, int cmd, sockptr_t arg,
unsigned int len) unsigned int len)
{ {
struct net *net = sock_net(sk); struct net *net = sock_net(sk);
...@@ -2381,18 +2378,18 @@ static int do_ebt_set_ctl(struct sock *sk, int cmd, void __user *user, ...@@ -2381,18 +2378,18 @@ static int do_ebt_set_ctl(struct sock *sk, int cmd, void __user *user,
case EBT_SO_SET_ENTRIES: case EBT_SO_SET_ENTRIES:
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
if (in_compat_syscall()) if (in_compat_syscall())
ret = compat_do_replace(net, user, len); ret = compat_do_replace(net, arg, len);
else else
#endif #endif
ret = do_replace(net, user, len); ret = do_replace(net, arg, len);
break; break;
case EBT_SO_SET_COUNTERS: case EBT_SO_SET_COUNTERS:
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
if (in_compat_syscall()) if (in_compat_syscall())
ret = compat_update_counters(net, user, len); ret = compat_update_counters(net, arg, len);
else else
#endif #endif
ret = update_counters(net, user, len); ret = update_counters(net, arg, len);
break; break;
default: default:
ret = -EINVAL; ret = -EINVAL;
......
...@@ -1332,7 +1332,8 @@ static int dn_setsockopt(struct socket *sock, int level, int optname, char __use ...@@ -1332,7 +1332,8 @@ static int dn_setsockopt(struct socket *sock, int level, int optname, char __use
/* we need to exclude all possible ENOPROTOOPTs except default case */ /* we need to exclude all possible ENOPROTOOPTs except default case */
if (err == -ENOPROTOOPT && optname != DSO_LINKINFO && if (err == -ENOPROTOOPT && optname != DSO_LINKINFO &&
optname != DSO_STREAM && optname != DSO_SEQPACKET) optname != DSO_STREAM && optname != DSO_SEQPACKET)
err = nf_setsockopt(sk, PF_DECnet, optname, optval, optlen); err = nf_setsockopt(sk, PF_DECnet, optname,
USER_SOCKPTR(optval), optlen);
#endif #endif
return err; return err;
......
...@@ -1422,7 +1422,8 @@ int ip_setsockopt(struct sock *sk, int level, ...@@ -1422,7 +1422,8 @@ int ip_setsockopt(struct sock *sk, int level,
optname != IP_IPSEC_POLICY && optname != IP_IPSEC_POLICY &&
optname != IP_XFRM_POLICY && optname != IP_XFRM_POLICY &&
!ip_mroute_opt(optname)) !ip_mroute_opt(optname))
err = nf_setsockopt(sk, PF_INET, optname, optval, optlen); err = nf_setsockopt(sk, PF_INET, optname, USER_SOCKPTR(optval),
optlen);
#endif #endif
return err; return err;
} }
......
// SPDX-License-Identifier: GPL-2.0-only
/* /*
* Packet matching code for ARP packets. * Packet matching code for ARP packets.
* *
...@@ -947,8 +947,7 @@ static int __do_replace(struct net *net, const char *name, ...@@ -947,8 +947,7 @@ static int __do_replace(struct net *net, const char *name,
return ret; return ret;
} }
static int do_replace(struct net *net, const void __user *user, static int do_replace(struct net *net, sockptr_t arg, unsigned int len)
unsigned int len)
{ {
int ret; int ret;
struct arpt_replace tmp; struct arpt_replace tmp;
...@@ -956,7 +955,7 @@ static int do_replace(struct net *net, const void __user *user, ...@@ -956,7 +955,7 @@ static int do_replace(struct net *net, const void __user *user,
void *loc_cpu_entry; void *loc_cpu_entry;
struct arpt_entry *iter; struct arpt_entry *iter;
if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) if (copy_from_sockptr(&tmp, arg, sizeof(tmp)) != 0)
return -EFAULT; return -EFAULT;
/* overflow check */ /* overflow check */
...@@ -972,8 +971,8 @@ static int do_replace(struct net *net, const void __user *user, ...@@ -972,8 +971,8 @@ static int do_replace(struct net *net, const void __user *user,
return -ENOMEM; return -ENOMEM;
loc_cpu_entry = newinfo->entries; loc_cpu_entry = newinfo->entries;
if (copy_from_user(loc_cpu_entry, user + sizeof(tmp), sockptr_advance(arg, sizeof(tmp));
tmp.size) != 0) { if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) {
ret = -EFAULT; ret = -EFAULT;
goto free_newinfo; goto free_newinfo;
} }
...@@ -1244,8 +1243,7 @@ static int translate_compat_table(struct net *net, ...@@ -1244,8 +1243,7 @@ static int translate_compat_table(struct net *net,
return ret; return ret;
} }
static int compat_do_replace(struct net *net, void __user *user, static int compat_do_replace(struct net *net, sockptr_t arg, unsigned int len)
unsigned int len)
{ {
int ret; int ret;
struct compat_arpt_replace tmp; struct compat_arpt_replace tmp;
...@@ -1253,7 +1251,7 @@ static int compat_do_replace(struct net *net, void __user *user, ...@@ -1253,7 +1251,7 @@ static int compat_do_replace(struct net *net, void __user *user,
void *loc_cpu_entry; void *loc_cpu_entry;
struct arpt_entry *iter; struct arpt_entry *iter;
if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) if (copy_from_sockptr(&tmp, arg, sizeof(tmp)) != 0)
return -EFAULT; return -EFAULT;
/* overflow check */ /* overflow check */
...@@ -1269,7 +1267,8 @@ static int compat_do_replace(struct net *net, void __user *user, ...@@ -1269,7 +1267,8 @@ static int compat_do_replace(struct net *net, void __user *user,
return -ENOMEM; return -ENOMEM;
loc_cpu_entry = newinfo->entries; loc_cpu_entry = newinfo->entries;
if (copy_from_user(loc_cpu_entry, user + sizeof(tmp), tmp.size) != 0) { sockptr_advance(arg, sizeof(tmp));
if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) {
ret = -EFAULT; ret = -EFAULT;
goto free_newinfo; goto free_newinfo;
} }
...@@ -1401,7 +1400,8 @@ static int compat_get_entries(struct net *net, ...@@ -1401,7 +1400,8 @@ static int compat_get_entries(struct net *net,
} }
#endif #endif
static int do_arpt_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) static int do_arpt_set_ctl(struct sock *sk, int cmd, sockptr_t arg,
unsigned int len)
{ {
int ret; int ret;
...@@ -1412,14 +1412,14 @@ static int do_arpt_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned ...@@ -1412,14 +1412,14 @@ static int do_arpt_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned
case ARPT_SO_SET_REPLACE: case ARPT_SO_SET_REPLACE:
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
if (in_compat_syscall()) if (in_compat_syscall())
ret = compat_do_replace(sock_net(sk), user, len); ret = compat_do_replace(sock_net(sk), arg, len);
else else
#endif #endif
ret = do_replace(sock_net(sk), user, len); ret = do_replace(sock_net(sk), arg, len);
break; break;
case ARPT_SO_SET_ADD_COUNTERS: case ARPT_SO_SET_ADD_COUNTERS:
ret = do_add_counters(sock_net(sk), USER_SOCKPTR(user), len); ret = do_add_counters(sock_net(sk), arg, len);
break; break;
default: default:
......
...@@ -1102,7 +1102,7 @@ __do_replace(struct net *net, const char *name, unsigned int valid_hooks, ...@@ -1102,7 +1102,7 @@ __do_replace(struct net *net, const char *name, unsigned int valid_hooks,
} }
static int static int
do_replace(struct net *net, const void __user *user, unsigned int len) do_replace(struct net *net, sockptr_t arg, unsigned int len)
{ {
int ret; int ret;
struct ipt_replace tmp; struct ipt_replace tmp;
...@@ -1110,7 +1110,7 @@ do_replace(struct net *net, const void __user *user, unsigned int len) ...@@ -1110,7 +1110,7 @@ do_replace(struct net *net, const void __user *user, unsigned int len)
void *loc_cpu_entry; void *loc_cpu_entry;
struct ipt_entry *iter; struct ipt_entry *iter;
if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) if (copy_from_sockptr(&tmp, arg, sizeof(tmp)) != 0)
return -EFAULT; return -EFAULT;
/* overflow check */ /* overflow check */
...@@ -1126,8 +1126,8 @@ do_replace(struct net *net, const void __user *user, unsigned int len) ...@@ -1126,8 +1126,8 @@ do_replace(struct net *net, const void __user *user, unsigned int len)
return -ENOMEM; return -ENOMEM;
loc_cpu_entry = newinfo->entries; loc_cpu_entry = newinfo->entries;
if (copy_from_user(loc_cpu_entry, user + sizeof(tmp), sockptr_advance(arg, sizeof(tmp));
tmp.size) != 0) { if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) {
ret = -EFAULT; ret = -EFAULT;
goto free_newinfo; goto free_newinfo;
} }
...@@ -1484,7 +1484,7 @@ translate_compat_table(struct net *net, ...@@ -1484,7 +1484,7 @@ translate_compat_table(struct net *net,
} }
static int static int
compat_do_replace(struct net *net, void __user *user, unsigned int len) compat_do_replace(struct net *net, sockptr_t arg, unsigned int len)
{ {
int ret; int ret;
struct compat_ipt_replace tmp; struct compat_ipt_replace tmp;
...@@ -1492,7 +1492,7 @@ compat_do_replace(struct net *net, void __user *user, unsigned int len) ...@@ -1492,7 +1492,7 @@ compat_do_replace(struct net *net, void __user *user, unsigned int len)
void *loc_cpu_entry; void *loc_cpu_entry;
struct ipt_entry *iter; struct ipt_entry *iter;
if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) if (copy_from_sockptr(&tmp, arg, sizeof(tmp)) != 0)
return -EFAULT; return -EFAULT;
/* overflow check */ /* overflow check */
...@@ -1508,8 +1508,8 @@ compat_do_replace(struct net *net, void __user *user, unsigned int len) ...@@ -1508,8 +1508,8 @@ compat_do_replace(struct net *net, void __user *user, unsigned int len)
return -ENOMEM; return -ENOMEM;
loc_cpu_entry = newinfo->entries; loc_cpu_entry = newinfo->entries;
if (copy_from_user(loc_cpu_entry, user + sizeof(tmp), sockptr_advance(arg, sizeof(tmp));
tmp.size) != 0) { if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) {
ret = -EFAULT; ret = -EFAULT;
goto free_newinfo; goto free_newinfo;
} }
...@@ -1610,7 +1610,7 @@ compat_get_entries(struct net *net, struct compat_ipt_get_entries __user *uptr, ...@@ -1610,7 +1610,7 @@ compat_get_entries(struct net *net, struct compat_ipt_get_entries __user *uptr,
#endif #endif
static int static int
do_ipt_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) do_ipt_set_ctl(struct sock *sk, int cmd, sockptr_t arg, unsigned int len)
{ {
int ret; int ret;
...@@ -1621,14 +1621,14 @@ do_ipt_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) ...@@ -1621,14 +1621,14 @@ do_ipt_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len)
case IPT_SO_SET_REPLACE: case IPT_SO_SET_REPLACE:
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
if (in_compat_syscall()) if (in_compat_syscall())
ret = compat_do_replace(sock_net(sk), user, len); ret = compat_do_replace(sock_net(sk), arg, len);
else else
#endif #endif
ret = do_replace(sock_net(sk), user, len); ret = do_replace(sock_net(sk), arg, len);
break; break;
case IPT_SO_SET_ADD_COUNTERS: case IPT_SO_SET_ADD_COUNTERS:
ret = do_add_counters(sock_net(sk), USER_SOCKPTR(user), len); ret = do_add_counters(sock_net(sk), arg, len);
break; break;
default: default:
......
...@@ -996,7 +996,8 @@ int ipv6_setsockopt(struct sock *sk, int level, int optname, ...@@ -996,7 +996,8 @@ int ipv6_setsockopt(struct sock *sk, int level, int optname,
/* we need to exclude all possible ENOPROTOOPTs except default case */ /* we need to exclude all possible ENOPROTOOPTs except default case */
if (err == -ENOPROTOOPT && optname != IPV6_IPSEC_POLICY && if (err == -ENOPROTOOPT && optname != IPV6_IPSEC_POLICY &&
optname != IPV6_XFRM_POLICY) optname != IPV6_XFRM_POLICY)
err = nf_setsockopt(sk, PF_INET6, optname, optval, optlen); err = nf_setsockopt(sk, PF_INET6, optname, USER_SOCKPTR(optval),
optlen);
#endif #endif
return err; return err;
} }
......
...@@ -1119,7 +1119,7 @@ __do_replace(struct net *net, const char *name, unsigned int valid_hooks, ...@@ -1119,7 +1119,7 @@ __do_replace(struct net *net, const char *name, unsigned int valid_hooks,
} }
static int static int
do_replace(struct net *net, const void __user *user, unsigned int len) do_replace(struct net *net, sockptr_t arg, unsigned int len)
{ {
int ret; int ret;
struct ip6t_replace tmp; struct ip6t_replace tmp;
...@@ -1127,7 +1127,7 @@ do_replace(struct net *net, const void __user *user, unsigned int len) ...@@ -1127,7 +1127,7 @@ do_replace(struct net *net, const void __user *user, unsigned int len)
void *loc_cpu_entry; void *loc_cpu_entry;
struct ip6t_entry *iter; struct ip6t_entry *iter;
if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) if (copy_from_sockptr(&tmp, arg, sizeof(tmp)) != 0)
return -EFAULT; return -EFAULT;
/* overflow check */ /* overflow check */
...@@ -1143,8 +1143,8 @@ do_replace(struct net *net, const void __user *user, unsigned int len) ...@@ -1143,8 +1143,8 @@ do_replace(struct net *net, const void __user *user, unsigned int len)
return -ENOMEM; return -ENOMEM;
loc_cpu_entry = newinfo->entries; loc_cpu_entry = newinfo->entries;
if (copy_from_user(loc_cpu_entry, user + sizeof(tmp), sockptr_advance(arg, sizeof(tmp));
tmp.size) != 0) { if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) {
ret = -EFAULT; ret = -EFAULT;
goto free_newinfo; goto free_newinfo;
} }
...@@ -1493,7 +1493,7 @@ translate_compat_table(struct net *net, ...@@ -1493,7 +1493,7 @@ translate_compat_table(struct net *net,
} }
static int static int
compat_do_replace(struct net *net, void __user *user, unsigned int len) compat_do_replace(struct net *net, sockptr_t arg, unsigned int len)
{ {
int ret; int ret;
struct compat_ip6t_replace tmp; struct compat_ip6t_replace tmp;
...@@ -1501,7 +1501,7 @@ compat_do_replace(struct net *net, void __user *user, unsigned int len) ...@@ -1501,7 +1501,7 @@ compat_do_replace(struct net *net, void __user *user, unsigned int len)
void *loc_cpu_entry; void *loc_cpu_entry;
struct ip6t_entry *iter; struct ip6t_entry *iter;
if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) if (copy_from_sockptr(&tmp, arg, sizeof(tmp)) != 0)
return -EFAULT; return -EFAULT;
/* overflow check */ /* overflow check */
...@@ -1517,8 +1517,8 @@ compat_do_replace(struct net *net, void __user *user, unsigned int len) ...@@ -1517,8 +1517,8 @@ compat_do_replace(struct net *net, void __user *user, unsigned int len)
return -ENOMEM; return -ENOMEM;
loc_cpu_entry = newinfo->entries; loc_cpu_entry = newinfo->entries;
if (copy_from_user(loc_cpu_entry, user + sizeof(tmp), sockptr_advance(arg, sizeof(tmp));
tmp.size) != 0) { if (copy_from_sockptr(loc_cpu_entry, arg, tmp.size) != 0) {
ret = -EFAULT; ret = -EFAULT;
goto free_newinfo; goto free_newinfo;
} }
...@@ -1619,7 +1619,7 @@ compat_get_entries(struct net *net, struct compat_ip6t_get_entries __user *uptr, ...@@ -1619,7 +1619,7 @@ compat_get_entries(struct net *net, struct compat_ip6t_get_entries __user *uptr,
#endif #endif
static int static int
do_ip6t_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) do_ip6t_set_ctl(struct sock *sk, int cmd, sockptr_t arg, unsigned int len)
{ {
int ret; int ret;
...@@ -1630,14 +1630,14 @@ do_ip6t_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) ...@@ -1630,14 +1630,14 @@ do_ip6t_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len)
case IP6T_SO_SET_REPLACE: case IP6T_SO_SET_REPLACE:
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
if (in_compat_syscall()) if (in_compat_syscall())
ret = compat_do_replace(sock_net(sk), user, len); ret = compat_do_replace(sock_net(sk), arg, len);
else else
#endif #endif
ret = do_replace(sock_net(sk), user, len); ret = do_replace(sock_net(sk), arg, len);
break; break;
case IP6T_SO_SET_ADD_COUNTERS: case IP6T_SO_SET_ADD_COUNTERS:
ret = do_add_counters(sock_net(sk), USER_SOCKPTR(user), len); ret = do_add_counters(sock_net(sk), arg, len);
break; break;
default: default:
......
...@@ -2434,7 +2434,7 @@ static void ip_vs_copy_udest_compat(struct ip_vs_dest_user_kern *udest, ...@@ -2434,7 +2434,7 @@ static void ip_vs_copy_udest_compat(struct ip_vs_dest_user_kern *udest,
} }
static int static int
do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) do_ip_vs_set_ctl(struct sock *sk, int cmd, sockptr_t ptr, unsigned int len)
{ {
struct net *net = sock_net(sk); struct net *net = sock_net(sk);
int ret; int ret;
...@@ -2458,7 +2458,7 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len) ...@@ -2458,7 +2458,7 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, void __user *user, unsigned int len)
return -EINVAL; return -EINVAL;
} }
if (copy_from_user(arg, user, len) != 0) if (copy_from_sockptr(arg, ptr, len) != 0)
return -EFAULT; return -EFAULT;
/* Handle daemons since they have another lock */ /* Handle daemons since they have another lock */
......
...@@ -89,7 +89,7 @@ static struct nf_sockopt_ops *nf_sockopt_find(struct sock *sk, u_int8_t pf, ...@@ -89,7 +89,7 @@ static struct nf_sockopt_ops *nf_sockopt_find(struct sock *sk, u_int8_t pf,
return ops; return ops;
} }
int nf_setsockopt(struct sock *sk, u_int8_t pf, int val, char __user *opt, int nf_setsockopt(struct sock *sk, u_int8_t pf, int val, sockptr_t opt,
unsigned int len) unsigned int len)
{ {
struct nf_sockopt_ops *ops; struct nf_sockopt_ops *ops;
......
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