[PATCH ipsec v2 0/1] xfrm: free the policies already cloned when a socket clone fails

Kyuwon Cho posted 1 patch 5 hours ago
net/xfrm/xfrm_policy.c | 7 +++++++
1 file changed, 7 insertions(+)
[PATCH ipsec v2 0/1] xfrm: free the policies already cloned when a socket clone fails
Posted by Kyuwon Cho 5 hours ago
When cloning a listener's second socket policy fails in sk_clone(),
the clone of the first one is leaked until its namespace goes away,
where xfrm_policy_fini() warns. The patch deletes the policies cloned
so far before __xfrm_sk_clone_policy() returns the error.

The issue was found by an LLM-guided test generator that we are
developing as a research prototype.

v2:
- Check the new socket's own slot instead of reading the parent's slot
  again, which a concurrent setsockopt() on the listener can change
  (Sashiko review).
- Send the patch inline, with its own changelog.
v1: https://lore.kernel.org/netdev/179505710269.3511679.8893709762919027206@gmail.com/

The patch was written with LLM assistance; we reviewed and tested it.
With it, the reproducer from v1 no longer triggers the warning.

Kyuwon Cho (1):
  xfrm: free the policies already cloned when a socket clone fails

 net/xfrm/xfrm_policy.c | 7 +++++++
 1 file changed, 7 insertions(+)

-- 
2.43.0