aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2016-04-07 01:07:34 -0400
committerDavid S. Miller <davem@davemloft.net>2016-04-07 12:02:33 -0400
commit8501786929de4616b10b8059ad97abd304a7dddf (patch)
treea523430f65bfddf7b2988d8cee3c08f23f2c5e68
parent94ab1ea94c71b7ba3e835315d69880a8086d7ab1 (diff)
tcp/dccp: fix inet_reuseport_add_sock()
David Ahern reported panics in __inet_hash() caused by my recent commit. The reason is inet_reuseport_add_sock() was still using sk_nulls_for_each_rcu() instead of sk_for_each_rcu(). SO_REUSEPORT enabled listeners were causing an instant crash. While chasing this bug, I found that I forgot to clear SOCK_RCU_FREE flag, as it is inherited from the parent at clone time. Fixes: 3b24d854cb35 ("tcp/dccp: do not touch listener sk_refcnt under synflood") Signed-off-by: Eric Dumazet <edumazet@google.com> Reported-by: David Ahern <dsa@cumulusnetworks.com> Tested-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/ipv4/inet_connection_sock.c3
-rw-r--r--net/ipv4/inet_hashtables.c3
2 files changed, 4 insertions, 2 deletions
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index bc5196ea1bdf..ab69da2d2a77 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -661,6 +661,9 @@ struct sock *inet_csk_clone_lock(const struct sock *sk,
661 inet_sk(newsk)->inet_sport = htons(inet_rsk(req)->ir_num); 661 inet_sk(newsk)->inet_sport = htons(inet_rsk(req)->ir_num);
662 newsk->sk_write_space = sk_stream_write_space; 662 newsk->sk_write_space = sk_stream_write_space;
663 663
664 /* listeners have SOCK_RCU_FREE, not the children */
665 sock_reset_flag(newsk, SOCK_RCU_FREE);
666
664 newsk->sk_mark = inet_rsk(req)->ir_mark; 667 newsk->sk_mark = inet_rsk(req)->ir_mark;
665 atomic64_set(&newsk->sk_cookie, 668 atomic64_set(&newsk->sk_cookie,
666 atomic64_read(&inet_rsk(req)->ir_cookie)); 669 atomic64_read(&inet_rsk(req)->ir_cookie));
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index 98ba03b6f87d..fcadb670f50b 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -439,10 +439,9 @@ static int inet_reuseport_add_sock(struct sock *sk,
439 bool match_wildcard)) 439 bool match_wildcard))
440{ 440{
441 struct sock *sk2; 441 struct sock *sk2;
442 struct hlist_nulls_node *node;
443 kuid_t uid = sock_i_uid(sk); 442 kuid_t uid = sock_i_uid(sk);
444 443
445 sk_nulls_for_each_rcu(sk2, node, &ilb->head) { 444 sk_for_each_rcu(sk2, &ilb->head) {
446 if (sk2 != sk && 445 if (sk2 != sk &&
447 sk2->sk_family == sk->sk_family && 446 sk2->sk_family == sk->sk_family &&
448 ipv6_only_sock(sk2) == ipv6_only_sock(sk) && 447 ipv6_only_sock(sk2) == ipv6_only_sock(sk) &&