]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-5.1/ipv6-consider-sk_bound_dev_if-when-binding-a-raw-socket-to-an-address.patch
083003b03175dc41bda2d00c2b00f7f451ff1158
[thirdparty/kernel/stable-queue.git] / queue-5.1 / ipv6-consider-sk_bound_dev_if-when-binding-a-raw-socket-to-an-address.patch
1 From foo@baz Fri 31 May 2019 03:16:39 PM PDT
2 From: Mike Manning <mmanning@vyatta.att-mail.com>
3 Date: Mon, 20 May 2019 19:57:17 +0100
4 Subject: ipv6: Consider sk_bound_dev_if when binding a raw socket to an address
5
6 From: Mike Manning <mmanning@vyatta.att-mail.com>
7
8 [ Upstream commit 72f7cfab6f93a8ea825fab8ccfb016d064269f7f ]
9
10 IPv6 does not consider if the socket is bound to a device when binding
11 to an address. The result is that a socket can be bound to eth0 and
12 then bound to the address of eth1. If the device is a VRF, the result
13 is that a socket can only be bound to an address in the default VRF.
14
15 Resolve by considering the device if sk_bound_dev_if is set.
16
17 Signed-off-by: Mike Manning <mmanning@vyatta.att-mail.com>
18 Reviewed-by: David Ahern <dsahern@gmail.com>
19 Tested-by: David Ahern <dsahern@gmail.com>
20 Signed-off-by: David S. Miller <davem@davemloft.net>
21 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22 ---
23 net/ipv6/raw.c | 2 ++
24 1 file changed, 2 insertions(+)
25
26 --- a/net/ipv6/raw.c
27 +++ b/net/ipv6/raw.c
28 @@ -287,7 +287,9 @@ static int rawv6_bind(struct sock *sk, s
29 /* Binding to link-local address requires an interface */
30 if (!sk->sk_bound_dev_if)
31 goto out_unlock;
32 + }
33
34 + if (sk->sk_bound_dev_if) {
35 err = -ENODEV;
36 dev = dev_get_by_index_rcu(sock_net(sk),
37 sk->sk_bound_dev_if);