WSL2-Linux-Kernel/drivers/net/wireguard
Jason A. Donenfeld 6147f7b1e9 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>
2020-09-09 11:31:38 -07:00
..
selftest wireguard: noise: separate receive counter from send counter 2020-05-20 20:55:09 -07:00
Makefile
allowedips.c wireguard: allowedips: fix use-after-free in root_remove_peer_lists 2020-02-05 14:14:18 +01:00
allowedips.h
cookie.c
cookie.h
device.c wireguard: implement header_ops->parse_protocol for AF_PACKET 2020-06-30 12:29:39 -07:00
device.h wireguard: device: avoid circular netns references 2020-06-23 14:50:34 -07:00
main.c wireguard: main: remove unused include <linux/version.h> 2019-12-16 19:22:22 -08:00
messages.h wireguard: queueing: preserve flow hash across packet scrubbing 2020-05-20 20:55:09 -07:00
netlink.c wireguard: device: avoid circular netns references 2020-06-23 14:50:34 -07:00
netlink.h
noise.c wireguard: noise: take lock when removing handshake entry from table 2020-09-09 11:31:37 -07:00
noise.h wireguard: noise: separate receive counter from send counter 2020-05-20 20:55:09 -07:00
peer.c mm, treewide: rename kzfree() to kfree_sensitive() 2020-08-07 11:33:22 -07:00
peer.h
peerlookup.c wireguard: peerlookup: take lock before checking hash in replace operation 2020-09-09 11:31:38 -07:00
peerlookup.h
queueing.c wireguard: queueing: cleanup ptr_ring in error path of packet_queue_init 2020-04-29 14:23:05 -07:00
queueing.h wireguard: queueing: make use of ip_tunnel_parse_protocol 2020-06-30 12:29:39 -07:00
ratelimiter.c
ratelimiter.h
receive.c wireguard: queueing: make use of ip_tunnel_parse_protocol 2020-06-30 12:29:39 -07:00
send.c wireguard: noise: separate receive counter from send counter 2020-05-20 20:55:09 -07:00
socket.c wireguard: device: avoid circular netns references 2020-06-23 14:50:34 -07:00
socket.h
timers.c
timers.h
version.h