Skip to contentSkip to conversation

inet: don't use sk_v6_rcv_saddr directly

PATCH Applied Josef Bacik 2 participants 3 messages Jan 20, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 inet: don't use sk_v6_rcv_saddr directly

When comparing two sockets we need to use inet6_rcv_saddr so we get a NULL sk_v6_rcv_saddr if the socket isn't AF_INET6, otherwise our comparison function can be wrong.

Fixes 637bc8b ("inet: reset tb->fastreuseport when adding a reuseport sk")
---
 net/ipv4/inet_connection_sock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/inet_connection_sock.c +1 -1
index 096a085..a336c42 100644
@@ -99,7 +99,7 @@ int inet_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2,
 #if IS_ENABLED(CONFIG_IPV6)
 	if (sk->sk_family == AF_INET6)
 		return ipv6_rcv_saddr_equal(&sk->sk_v6_rcv_saddr,
-					    &sk2->sk_v6_rcv_saddr,
+					    inet6_rcv_saddr(sk2),
 					    sk->sk_rcv_saddr,
 					    sk2->sk_rcv_saddr,
 					    ipv6_only_sock(sk),
Signature · 1 line
2.5.5
#1 lore raw
Quoted 23 lines · Josef Bacik

When comparing two sockets we need to use inet6_rcv_saddr so we get a NULL sk_v6_rcv_saddr if the socket isn't AF_INET6, otherwise our comparison function can be wrong.

Fixes 637bc8b ("inet: reset tb->fastreuseport when adding a reuseport sk")
---
 net/ipv4/inet_connection_sock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/inet_connection_sock.c +1 -1
index 096a085..a336c42 100644
@@ -99,7 +99,7 @@ int inet_rcv_saddr_equal(const struct sock *sk, 
 const struct sock *sk2,
 #if IS_ENABLED(CONFIG_IPV6)
 	if (sk->sk_family == AF_INET6)
 		return ipv6_rcv_saddr_equal(&sk->sk_v6_rcv_saddr,
-					    &sk2->sk_v6_rcv_saddr,
+					    inet6_rcv_saddr(sk2),
 					    sk->sk_rcv_saddr,
 					    sk2->sk_rcv_saddr,
Quoted 3 lines

ipv6_only_sock(sk),
--
2.5.5

Sorry I forgot to tag this, it's for net-next. Thanks,

Josef

maintainer Applied
#2 lore raw
In reply to Josef Bacik

From: Josef Bacik <[email protected]>
Date: Thu, 19 Jan 2017 17:47:46 -0500

Quoted 6 lines

When comparing two sockets we need to use inet6_rcv_saddr so we get a NULL sk_v6_rcv_saddr if the socket isn't AF_INET6, otherwise our comparison function can be wrong.

Fixes 637bc8b ("inet: reset tb->fastreuseport when adding a reuseport sk")

Applied, thanks.