Patch "tcp: Fix bind() conflict check for dual-stack wildcard address." has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    tcp: Fix bind() conflict check for dual-stack wildcard address.

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     tcp-fix-bind-conflict-check-for-dual-stack-wildcard-.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 0c0caadafc198c63a1192c3f6a97e9cad079a5a7
Author: Kuniyuki Iwashima <kuniyu@xxxxxxxxxx>
Date:   Sat Mar 11 19:19:03 2023 -0800

    tcp: Fix bind() conflict check for dual-stack wildcard address.
    
    [ Upstream commit d9ba9934285514f1f95d96326a82398a22dc77f2 ]
    
    Paul Holzinger reported [0] that commit 5456262d2baa ("net: Fix
    incorrect address comparison when searching for a bind2 bucket")
    introduced a bind() regression.  Paul also gave a nice repro that
    calls two types of bind() on the same port, both of which now
    succeed, but the second call should fail:
    
      bind(fd1, ::, port) + bind(fd2, 127.0.0.1, port)
    
    The cited commit added address family tests in three functions to
    fix the uninit-value KMSAN report. [1]  However, the test added to
    inet_bind2_bucket_match_addr_any() removed a necessary conflict
    check; the dual-stack wildcard address no longer conflicts with
    an IPv4 non-wildcard address.
    
    If tb->family is AF_INET6 and sk->sk_family is AF_INET in
    inet_bind2_bucket_match_addr_any(), we still need to check
    if tb has the dual-stack wildcard address.
    
    Note that the IPv4 wildcard address does not conflict with
    IPv6 non-wildcard addresses.
    
    [0]: https://lore.kernel.org/netdev/e21bf153-80b0-9ec0-15ba-e04a4ad42c34@xxxxxxxxxx/
    [1]: https://lore.kernel.org/netdev/CAG_fn=Ud3zSW7AZWXc+asfMhZVL5ETnvuY44Pmyv4NPv-ijN-A@xxxxxxxxxxxxxx/
    
    Fixes: 5456262d2baa ("net: Fix incorrect address comparison when searching for a bind2 bucket")
    Signed-off-by: Kuniyuki Iwashima <kuniyu@xxxxxxxxxx>
    Reported-by: Paul Holzinger <pholzing@xxxxxxxxxx>
    Link: https://lore.kernel.org/netdev/CAG_fn=Ud3zSW7AZWXc+asfMhZVL5ETnvuY44Pmyv4NPv-ijN-A@xxxxxxxxxxxxxx/
    Reviewed-by: Eric Dumazet <edumazet@xxxxxxxxxx>
    Tested-by: Paul Holzinger <pholzing@xxxxxxxxxx>
    Reviewed-by: Martin KaFai Lau <martin.lau@xxxxxxxxxx>
    Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index cd8b2f7a8f341..f0750c06d5ffc 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -828,8 +828,14 @@ bool inet_bind2_bucket_match_addr_any(const struct inet_bind2_bucket *tb, const
 #if IS_ENABLED(CONFIG_IPV6)
 	struct in6_addr addr_any = {};
 
-	if (sk->sk_family != tb->family)
+	if (sk->sk_family != tb->family) {
+		if (sk->sk_family == AF_INET)
+			return net_eq(ib2_net(tb), net) && tb->port == port &&
+				tb->l3mdev == l3mdev &&
+				ipv6_addr_equal(&tb->v6_rcv_saddr, &addr_any);
+
 		return false;
+	}
 
 	if (sk->sk_family == AF_INET6)
 		return net_eq(ib2_net(tb), net) && tb->port == port &&



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux