Commit ec0506db authored by Maciej Żenczykowski's avatar Maciej Żenczykowski Committed by David S. Miller

net: relax PKTINFO non local ipv6 udp xmit check

Allow transparent sockets to be less restrictive about
the source ip of ipv6 udp packets being sent.

Google-Bug-Id: 5018138
Signed-off-by: default avatarMaciej Żenczykowski <maze@google.com>
CC: "Erik Kline" <ek@google.com>
CC: "Lorenzo Colitti" <lorenzo@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0f43dd54
...@@ -39,6 +39,7 @@ extern int datagram_recv_ctl(struct sock *sk, ...@@ -39,6 +39,7 @@ extern int datagram_recv_ctl(struct sock *sk,
struct sk_buff *skb); struct sk_buff *skb);
extern int datagram_send_ctl(struct net *net, extern int datagram_send_ctl(struct net *net,
struct sock *sk,
struct msghdr *msg, struct msghdr *msg,
struct flowi6 *fl6, struct flowi6 *fl6,
struct ipv6_txoptions *opt, struct ipv6_txoptions *opt,
......
...@@ -599,7 +599,7 @@ int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb) ...@@ -599,7 +599,7 @@ int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb)
return 0; return 0;
} }
int datagram_send_ctl(struct net *net, int datagram_send_ctl(struct net *net, struct sock *sk,
struct msghdr *msg, struct flowi6 *fl6, struct msghdr *msg, struct flowi6 *fl6,
struct ipv6_txoptions *opt, struct ipv6_txoptions *opt,
int *hlimit, int *tclass, int *dontfrag) int *hlimit, int *tclass, int *dontfrag)
...@@ -658,7 +658,8 @@ int datagram_send_ctl(struct net *net, ...@@ -658,7 +658,8 @@ int datagram_send_ctl(struct net *net,
if (addr_type != IPV6_ADDR_ANY) { if (addr_type != IPV6_ADDR_ANY) {
int strict = __ipv6_addr_src_scope(addr_type) <= IPV6_ADDR_SCOPE_LINKLOCAL; int strict = __ipv6_addr_src_scope(addr_type) <= IPV6_ADDR_SCOPE_LINKLOCAL;
if (!ipv6_chk_addr(net, &src_info->ipi6_addr, if (!inet_sk(sk)->transparent &&
!ipv6_chk_addr(net, &src_info->ipi6_addr,
strict ? dev : NULL, 0)) strict ? dev : NULL, 0))
err = -EINVAL; err = -EINVAL;
else else
......
...@@ -322,8 +322,8 @@ static int fl6_renew(struct ip6_flowlabel *fl, unsigned long linger, unsigned lo ...@@ -322,8 +322,8 @@ 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 in6_flowlabel_req *freq, char __user *optval, fl_create(struct net *net, struct sock *sk, struct in6_flowlabel_req *freq,
int optlen, int *err_p) char __user *optval, int optlen, int *err_p)
{ {
struct ip6_flowlabel *fl = NULL; struct ip6_flowlabel *fl = NULL;
int olen; int olen;
...@@ -360,7 +360,7 @@ fl_create(struct net *net, struct in6_flowlabel_req *freq, char __user *optval, ...@@ -360,7 +360,7 @@ fl_create(struct net *net, struct in6_flowlabel_req *freq, char __user *optval,
msg.msg_control = (void*)(fl->opt+1); msg.msg_control = (void*)(fl->opt+1);
memset(&flowi6, 0, sizeof(flowi6)); memset(&flowi6, 0, sizeof(flowi6));
err = datagram_send_ctl(net, &msg, &flowi6, fl->opt, &junk, err = datagram_send_ctl(net, sk, &msg, &flowi6, fl->opt, &junk,
&junk, &junk); &junk, &junk);
if (err) if (err)
goto done; goto done;
...@@ -528,7 +528,7 @@ int ipv6_flowlabel_opt(struct sock *sk, char __user *optval, int optlen) ...@@ -528,7 +528,7 @@ int ipv6_flowlabel_opt(struct sock *sk, char __user *optval, int optlen)
if (freq.flr_label & ~IPV6_FLOWLABEL_MASK) if (freq.flr_label & ~IPV6_FLOWLABEL_MASK)
return -EINVAL; return -EINVAL;
fl = fl_create(net, &freq, optval, optlen, &err); fl = fl_create(net, sk, &freq, optval, optlen, &err);
if (fl == NULL) if (fl == NULL)
return err; return err;
sfl1 = kmalloc(sizeof(*sfl1), GFP_KERNEL); sfl1 = kmalloc(sizeof(*sfl1), GFP_KERNEL);
......
...@@ -475,7 +475,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, ...@@ -475,7 +475,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
msg.msg_controllen = optlen; msg.msg_controllen = optlen;
msg.msg_control = (void*)(opt+1); msg.msg_control = (void*)(opt+1);
retv = datagram_send_ctl(net, &msg, &fl6, opt, &junk, &junk, retv = datagram_send_ctl(net, sk, &msg, &fl6, opt, &junk, &junk,
&junk); &junk);
if (retv) if (retv)
goto done; goto done;
......
...@@ -817,8 +817,8 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -817,8 +817,8 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
memset(opt, 0, sizeof(struct ipv6_txoptions)); memset(opt, 0, sizeof(struct ipv6_txoptions));
opt->tot_len = sizeof(struct ipv6_txoptions); opt->tot_len = sizeof(struct ipv6_txoptions);
err = datagram_send_ctl(sock_net(sk), msg, &fl6, opt, &hlimit, err = datagram_send_ctl(sock_net(sk), sk, msg, &fl6, opt,
&tclass, &dontfrag); &hlimit, &tclass, &dontfrag);
if (err < 0) { if (err < 0) {
fl6_sock_release(flowlabel); fl6_sock_release(flowlabel);
return err; return err;
......
...@@ -1090,8 +1090,8 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -1090,8 +1090,8 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
memset(opt, 0, sizeof(struct ipv6_txoptions)); memset(opt, 0, sizeof(struct ipv6_txoptions));
opt->tot_len = sizeof(*opt); opt->tot_len = sizeof(*opt);
err = datagram_send_ctl(sock_net(sk), msg, &fl6, opt, &hlimit, err = datagram_send_ctl(sock_net(sk), sk, msg, &fl6, opt,
&tclass, &dontfrag); &hlimit, &tclass, &dontfrag);
if (err < 0) { if (err < 0) {
fl6_sock_release(flowlabel); fl6_sock_release(flowlabel);
return err; return err;
......
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