]> git.baikalelectronics.ru Git - kernel.git/commit
wireguard: device: avoid circular netns references
authorJason A. Donenfeld <Jason@zx2c4.com>
Tue, 23 Jun 2020 09:59:45 +0000 (03:59 -0600)
committerDavid S. Miller <davem@davemloft.net>
Tue, 23 Jun 2020 21:50:34 +0000 (14:50 -0700)
commiteb453e387def13a8e93e6eeec110492b6e9dc7d2
treebc2af98abab2084854244d25f925484390b038ad
parent50bb81e30a6fd4a559ee8e922c016b1d2f405b4e
wireguard: device: avoid circular netns references

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: 0c73bbc77a76 ("net: WireGuard secure network tunnel")
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/wireguard/device.c
drivers/net/wireguard/device.h
drivers/net/wireguard/netlink.c
drivers/net/wireguard/socket.c
tools/testing/selftests/wireguard/netns.sh