tcp_v4_err() passes 0 sdif to __inet_lookup_established(). So, ICMP error coming from VRF can be leaked to a socket not bound to the device. For example, this test fails at the last assert because the socket receives ICMP error: --ip_version=ipv4 0 socket(..., SOCK_STREAM|SOCK_NONBLOCK, IPPROTO_TCP) = 3 +0 connect(3, ..., ...) = -1 EINPROGRESS (Operation now in progress) +0 > S 0:0(0) <...> +0 `ip link add vrf0 type vrf table 10` +0 `ip link set vrf0 up` +0 `ip link set dev tun0 master vrf0` +0 `ip route add 192.0.2.0/24 dev tun0 table 10` +0 < icmp unreachable port_unreachable [0:0(0)] +0 %{ assert tcpi_state == TCP_SYN_SENT, tcpi_state }% Let's pass inet_sdif() to __inet_lookup_established(). Fixes: 3fa6f616a7a4 ("net: ipv4: add second dif to inet socket lookups") Signed-off-by: Kuniyuki Iwashima --- Cc: David Ahern Cc: David Ahern --- net/ipv4/tcp_ipv4.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index bc909fedda3a..35a1309f8b21 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -504,7 +504,8 @@ int tcp_v4_err(struct sk_buff *skb, u32 info) int err; sk = __inet_lookup_established(net, iph->daddr, th->dest, iph->saddr, - ntohs(th->source), inet_iif(skb), 0); + ntohs(th->source), inet_iif(skb), + inet_sdif(skb)); if (!sk) { __ICMP_INC_STATS(net, ICMP_MIB_INERRORS); return -ENOENT; -- 2.56.0.679.gc527c65306-goog