Skip to content

xfrm: free the policies already cloned when a socket clone fails

Kyuwon Cho ipsec lkml netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest1 patch 2 repliesIn review

Changes in v2 from the cover letter

- 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/[email protected]/

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/1xfrm: free the policies already cloned when a socket clone failsnet/xfrm/xfrm_policy.c+7 -02 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

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

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/[email protected]/

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(+)
Signature · 1 line
2.43.0