]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/5.1.7/ipv6-consider-sk_bound_dev_if-when-binding-a-raw-socket-to-an-address.patch
Linux 5.1.7
[thirdparty/kernel/stable-queue.git] / releases / 5.1.7 / ipv6-consider-sk_bound_dev_if-when-binding-a-raw-socket-to-an-address.patch
CommitLineData
ffc20820
GKH
1From foo@baz Fri 31 May 2019 03:16:39 PM PDT
2From: Mike Manning <mmanning@vyatta.att-mail.com>
3Date: Mon, 20 May 2019 19:57:17 +0100
4Subject: ipv6: Consider sk_bound_dev_if when binding a raw socket to an address
5
6From: Mike Manning <mmanning@vyatta.att-mail.com>
7
8[ Upstream commit 72f7cfab6f93a8ea825fab8ccfb016d064269f7f ]
9
10IPv6 does not consider if the socket is bound to a device when binding
11to an address. The result is that a socket can be bound to eth0 and
12then bound to the address of eth1. If the device is a VRF, the result
13is that a socket can only be bound to an address in the default VRF.
14
15Resolve by considering the device if sk_bound_dev_if is set.
16
17Signed-off-by: Mike Manning <mmanning@vyatta.att-mail.com>
18Reviewed-by: David Ahern <dsahern@gmail.com>
19Tested-by: David Ahern <dsahern@gmail.com>
20Signed-off-by: David S. Miller <davem@davemloft.net>
21Signed-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);