linux/drivers/net/wireguard
Jason A. Donenfeld 8d81d0b465 UPSTREAM: wireguard: peerlookup: take lock before checking hash in replace operation
Eric's suggested fix for the previous commit's mentioned race condition
was to simply take the table->lock in wg_index_hashtable_replace(). The
table->lock of the hash table is supposed to protect the bucket heads,
not the entires, but actually, since all the mutator functions are
already taking it, it makes sense to take it too for the test to
hlist_unhashed, as a defense in depth measure, so that it no longer
races with deletions, regardless of what other locks are protecting
individual entries. This is sensible from a performance perspective
because, as Eric pointed out, the case of being unhashed is already the
unlikely case, so this won't add common contention. And comparing
instructions, this basically doesn't make much of a difference other
than pushing and popping %r13, used by the new `bool ret`. More
generally, I like the idea of locking consistency across table mutator
functions, and this might let me rest slightly easier at night.

Suggested-by: Eric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/wireguard/20200908145911.4090480-1-edumazet@google.com/
Fixes: e7096c131e ("net: WireGuard secure network tunnel")
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 6147f7b1e9)
Bug: 152722841
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I3f3c44100fe655f3f278dc8a57cee1171ced4147
2020-10-25 13:40:28 +01:00
..
selftest UPSTREAM: wireguard: noise: separate receive counter from send counter 2020-10-25 13:40:23 +01:00
allowedips.c UPSTREAM: wireguard: allowedips: fix use-after-free in root_remove_peer_lists 2020-10-25 13:40:06 +01:00
allowedips.h
cookie.c
cookie.h
device.c UPSTREAM: wireguard: device: avoid circular netns references 2020-10-25 13:40:24 +01:00
device.h UPSTREAM: wireguard: device: avoid circular netns references 2020-10-25 13:40:24 +01:00
main.c UPSTREAM: wireguard: main: remove unused include <linux/version.h> 2020-10-25 11:48:14 +01:00
Makefile
messages.h UPSTREAM: wireguard: queueing: preserve flow hash across packet scrubbing 2020-10-25 13:40:22 +01:00
netlink.c UPSTREAM: wireguard: device: avoid circular netns references 2020-10-25 13:40:24 +01:00
netlink.h
noise.c UPSTREAM: wireguard: noise: take lock when removing handshake entry from table 2020-10-25 13:40:27 +01:00
noise.h UPSTREAM: wireguard: noise: separate receive counter from send counter 2020-10-25 13:40:23 +01:00
peer.c UPSTREAM: wireguard: noise: error out precomputed DH during handshake rather than config 2020-10-25 13:40:14 +01:00
peer.h
peerlookup.c UPSTREAM: wireguard: peerlookup: take lock before checking hash in replace operation 2020-10-25 13:40:28 +01:00
peerlookup.h
queueing.c UPSTREAM: wireguard: queueing: cleanup ptr_ring in error path of packet_queue_init 2020-10-25 13:40:16 +01:00
queueing.h UPSTREAM: wireguard: queueing: make use of ip_tunnel_parse_protocol 2020-10-25 13:40:26 +01:00
ratelimiter.c
ratelimiter.h
receive.c UPSTREAM: wireguard: queueing: make use of ip_tunnel_parse_protocol 2020-10-25 13:40:26 +01:00
send.c UPSTREAM: wireguard: noise: separate receive counter from send counter 2020-10-25 13:40:23 +01:00
socket.c UPSTREAM: wireguard: device: avoid circular netns references 2020-10-25 13:40:24 +01:00
socket.h
timers.c
timers.h
version.h