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

net/ipv6: switch ipv6_flowlabel_opt to sockptr_t

Pass a sockptr_t to prepare for set_fs-less handling of the kernel
pointer from bpf-cgroup.

Note that the get case is pretty weird in that it actually copies data
back to userspace from setsockopt.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ff6a4cf2
...@@ -406,7 +406,7 @@ struct ipv6_txoptions *fl6_merge_options(struct ipv6_txoptions *opt_space, ...@@ -406,7 +406,7 @@ struct ipv6_txoptions *fl6_merge_options(struct ipv6_txoptions *opt_space,
struct ip6_flowlabel *fl, struct ip6_flowlabel *fl,
struct ipv6_txoptions *fopt); struct ipv6_txoptions *fopt);
void fl6_free_socklist(struct sock *sk); void fl6_free_socklist(struct sock *sk);
int ipv6_flowlabel_opt(struct sock *sk, char __user *optval, int optlen); int ipv6_flowlabel_opt(struct sock *sk, sockptr_t optval, int optlen);
int ipv6_flowlabel_opt_get(struct sock *sk, struct in6_flowlabel_req *freq, int ipv6_flowlabel_opt_get(struct sock *sk, struct in6_flowlabel_req *freq,
int flags); int flags);
int ip6_flowlabel_init(void); int ip6_flowlabel_init(void);
......
...@@ -371,7 +371,7 @@ static int fl6_renew(struct ip6_flowlabel *fl, unsigned long linger, unsigned lo ...@@ -371,7 +371,7 @@ static int fl6_renew(struct ip6_flowlabel *fl, unsigned long linger, unsigned lo
static struct ip6_flowlabel * static struct ip6_flowlabel *
fl_create(struct net *net, struct sock *sk, struct in6_flowlabel_req *freq, fl_create(struct net *net, struct sock *sk, struct in6_flowlabel_req *freq,
char __user *optval, int optlen, int *err_p) sockptr_t optval, int optlen, int *err_p)
{ {
struct ip6_flowlabel *fl = NULL; struct ip6_flowlabel *fl = NULL;
int olen; int olen;
...@@ -401,7 +401,8 @@ fl_create(struct net *net, struct sock *sk, struct in6_flowlabel_req *freq, ...@@ -401,7 +401,8 @@ fl_create(struct net *net, struct sock *sk, struct in6_flowlabel_req *freq,
memset(fl->opt, 0, sizeof(*fl->opt)); memset(fl->opt, 0, sizeof(*fl->opt));
fl->opt->tot_len = sizeof(*fl->opt) + olen; fl->opt->tot_len = sizeof(*fl->opt) + olen;
err = -EFAULT; err = -EFAULT;
if (copy_from_user(fl->opt+1, optval+CMSG_ALIGN(sizeof(*freq)), olen)) sockptr_advance(optval, CMSG_ALIGN(sizeof(*freq)));
if (copy_from_sockptr(fl->opt + 1, optval, olen))
goto done; goto done;
msg.msg_controllen = olen; msg.msg_controllen = olen;
...@@ -604,7 +605,7 @@ static int ipv6_flowlabel_renew(struct sock *sk, struct in6_flowlabel_req *freq) ...@@ -604,7 +605,7 @@ static int ipv6_flowlabel_renew(struct sock *sk, struct in6_flowlabel_req *freq)
} }
static int ipv6_flowlabel_get(struct sock *sk, struct in6_flowlabel_req *freq, static int ipv6_flowlabel_get(struct sock *sk, struct in6_flowlabel_req *freq,
void __user *optval, int optlen) sockptr_t optval, int optlen)
{ {
struct ipv6_fl_socklist *sfl, *sfl1 = NULL; struct ipv6_fl_socklist *sfl, *sfl1 = NULL;
struct ip6_flowlabel *fl, *fl1 = NULL; struct ip6_flowlabel *fl, *fl1 = NULL;
...@@ -702,8 +703,9 @@ static int ipv6_flowlabel_get(struct sock *sk, struct in6_flowlabel_req *freq, ...@@ -702,8 +703,9 @@ static int ipv6_flowlabel_get(struct sock *sk, struct in6_flowlabel_req *freq,
goto recheck; goto recheck;
if (!freq->flr_label) { if (!freq->flr_label) {
if (copy_to_user(&((struct in6_flowlabel_req __user *) optval)->flr_label, sockptr_advance(optval,
&fl->label, sizeof(fl->label))) { offsetof(struct in6_flowlabel_req, flr_label));
if (copy_to_sockptr(optval, &fl->label, sizeof(fl->label))) {
/* Intentionally ignore fault. */ /* Intentionally ignore fault. */
} }
} }
...@@ -716,13 +718,13 @@ static int ipv6_flowlabel_get(struct sock *sk, struct in6_flowlabel_req *freq, ...@@ -716,13 +718,13 @@ static int ipv6_flowlabel_get(struct sock *sk, struct in6_flowlabel_req *freq,
return err; return err;
} }
int ipv6_flowlabel_opt(struct sock *sk, char __user *optval, int optlen) int ipv6_flowlabel_opt(struct sock *sk, sockptr_t optval, int optlen)
{ {
struct in6_flowlabel_req freq; struct in6_flowlabel_req freq;
if (optlen < sizeof(freq)) if (optlen < sizeof(freq))
return -EINVAL; return -EINVAL;
if (copy_from_user(&freq, optval, sizeof(freq))) if (copy_from_sockptr(&freq, optval, sizeof(freq)))
return -EFAULT; return -EFAULT;
switch (freq.flr_action) { switch (freq.flr_action) {
......
...@@ -929,7 +929,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, ...@@ -929,7 +929,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
retv = 0; retv = 0;
break; break;
case IPV6_FLOWLABEL_MGR: case IPV6_FLOWLABEL_MGR:
retv = ipv6_flowlabel_opt(sk, optval, optlen); retv = ipv6_flowlabel_opt(sk, USER_SOCKPTR(optval), optlen);
break; break;
case IPV6_IPSEC_POLICY: case IPV6_IPSEC_POLICY:
case IPV6_XFRM_POLICY: case IPV6_XFRM_POLICY:
......
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