dccp/tcp: Update saddr under bhash's lock.
authorKuniyuki Iwashima <kuniyu@amazon.com>
Sat, 19 Nov 2022 01:49:13 +0000 (17:49 -0800)
committerJakub Kicinski <kuba@kernel.org>
Wed, 23 Nov 2022 04:15:36 +0000 (20:15 -0800)
commit8c5dae4c1a49489499e6708c7dd284370ca36287
tree1bd9f1c99ba56a33f537f5c30eafa2767266c1b9
parent8acdad37cd13ce777b0811b2d332314037fcefa8
dccp/tcp: Update saddr under bhash's lock.

When we call connect() for a socket bound to a wildcard address, we update
saddr locklessly.  However, it could result in a data race; another thread
iterating over bhash might see a corrupted address.

Let's update saddr under the bhash bucket's lock.

Fixes: 3df80d9320bc ("[DCCP]: Introduce DCCPv6")
Fixes: 7c657876b63c ("[DCCP]: Initial implementation")
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Acked-by: Joanne Koong <joannelkoong@gmail.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/net/inet_hashtables.h
net/dccp/ipv4.c
net/dccp/ipv6.c
net/ipv4/af_inet.c
net/ipv4/inet_hashtables.c
net/ipv4/tcp_ipv4.c
net/ipv6/tcp_ipv6.c