summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSabrina Dubroca <sd@queasysnail.net>2025-04-09 16:59:57 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-06-04 15:40:19 +0300
commite4cde54b46a87231c77256a633be1bef62687d69 (patch)
treedc910f81558d8860533b4e77e0f889af09e09e3a /include
parent9b0915e72b3cf52474dcee0b24a2f99d93e604a3 (diff)
downloadlinux-e4cde54b46a87231c77256a633be1bef62687d69.tar.xz
espintcp: remove encap socket caching to avoid reference leak
[ Upstream commit 028363685bd0b7a19b4a820f82dd905b1dc83999 ] The current scheme for caching the encap socket can lead to reference leaks when we try to delete the netns. The reference chain is: xfrm_state -> enacp_sk -> netns Since the encap socket is a userspace socket, it holds a reference on the netns. If we delete the espintcp state (through flush or individual delete) before removing the netns, the reference on the socket is dropped and the netns is correctly deleted. Otherwise, the netns may not be reachable anymore (if all processes within the ns have terminated), so we cannot delete the xfrm state to drop its reference on the socket. This patch results in a small (~2% in my tests) performance regression. A GC-type mechanism could be added for the socket cache, to clear references if the state hasn't been used "recently", but it's a lot more complex than just not caching the socket. Fixes: e27cca96cd68 ("xfrm: add espintcp (RFC 8229)") Signed-off-by: Sabrina Dubroca <sd@queasysnail.net> Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'include')
-rw-r--r--include/net/xfrm.h1
1 files changed, 0 insertions, 1 deletions
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index bf670929622d..64911162ab5f 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -212,7 +212,6 @@ struct xfrm_state {
/* Data for encapsulator */
struct xfrm_encap_tmpl *encap;
- struct sock __rcu *encap_sk;
/* Data for care-of address */
xfrm_address_t *coaddr;