summaryrefslogtreecommitdiff
path: root/drivers/net/wireguard/device.h
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-06-23 03:59:45 -0600
committerJason A. Donenfeld <Jason@zx2c4.com>2022-07-07 13:26:42 +0200
commit4ce27f5f1006e68e95df4410bb5f6681a507693f (patch)
treeb7c44da23bf498a4b898e975bc0ef12ccc017aa1 /drivers/net/wireguard/device.h
parent56bdfcf4cec966ecd18f13db1f172e5b6fe5bedb (diff)
downloadwireguard-linux-trimmed-4ce27f5f1006e68e95df4410bb5f6681a507693f.tar.gz
wireguard-linux-trimmed-4ce27f5f1006e68e95df4410bb5f6681a507693f.zip
wireguard: device: avoid circular netns references
commit be0d977e56c769b2610db430604ad7ff1ed31408 upstream. Before, we took a reference to the creating netns if the new netns was different. This caused issues with circular references, with two wireguard interfaces swapping namespaces. The solution is to rather not take any extra references at all, but instead simply invalidate the creating netns pointer when that netns is deleted. In order to prevent this from happening again, this commit improves the rough object leak tracking by allowing it to account for created and destroyed interfaces, aside from just peers and keys. That then makes it possible to check for the object leak when having two interfaces take a reference to each others' namespaces. Fixes: a8f1bc7bdea3 ("net: WireGuard secure network tunnel") Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'drivers/net/wireguard/device.h')
-rw-r--r--drivers/net/wireguard/device.h3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/net/wireguard/device.h b/drivers/net/wireguard/device.h
index b15a8be..4d0144e 100644
--- a/drivers/net/wireguard/device.h
+++ b/drivers/net/wireguard/device.h
@@ -40,7 +40,7 @@ struct wg_device {
struct net_device *dev;
struct crypt_queue encrypt_queue, decrypt_queue;
struct sock __rcu *sock4, *sock6;
- struct net *creating_net;
+ struct net __rcu *creating_net;
struct noise_static_identity static_identity;
struct workqueue_struct *handshake_receive_wq, *handshake_send_wq;
struct workqueue_struct *packet_crypt_wq;
@@ -56,7 +56,6 @@ struct wg_device {
unsigned int num_peers, device_update_gen;
u32 fwmark;
u16 incoming_port;
- bool have_creating_net_ref;
};
int wg_device_init(void);