Netdev List
 help / color / mirror / Atom feed
* [PATCH net] xfrm: delete migrated old states before dropping their references
@ 2026-11-06  9:02 Jun Yang
  2026-11-10  9:19 ` netdev-bot+sashiko
  0 siblings, 1 reply; 2+ messages in thread
From: Jun Yang @ 2026-11-06  9:02 UTC (permalink / raw)
  To: steffen.klassert, herbert
  Cc: davem, edumazet, kuba, pabeni, horms, shinta.sugimoto, yoshfuji,
	nakam, netdev, Jun Yang, stable, TencentOS Corvus AI

From: Jun Yang <junvyyang@tencent.com>

xfrm_migrate_state_find() returns a referenced old state, but
xfrm_migrate() drops the references in x_cur[] before deleting those
states. If an expiry timer or another concurrent deletion has already
removed a state from the table, the put can release its last reference,
leaving xfrm_state_delete() to access a freed state.

Delete the old states before dropping their lookup references, so they
remain alive throughout xfrm_states_delete().

Fixes: 80c9abaabf42 ("[XFRM]: Extension for dynamic update of endpoint address(es)")
Cc: stable@kernel.org
Reported-by: TencentOS Corvus AI <corvus@tencent.com>
Signed-off-by: Jun Yang <junvyyang@tencent.com>
---
A KASAN reproducer for this issue is available if requested.

 net/xfrm/xfrm_policy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 9ea60c7717ff..5d818c1ec9e4 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -4722,8 +4722,8 @@ int xfrm_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
 
 	/* Stage 4 - delete old state(s) */
 	if (nx_cur) {
-		xfrm_states_put(x_cur, nx_cur);
 		xfrm_states_delete(x_cur, nx_cur);
+		xfrm_states_put(x_cur, nx_cur);
 	}
 
 	/* Stage 5 - announce */
-- 
2.43.7


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-10  9:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-06  9:02 [PATCH net] xfrm: delete migrated old states before dropping their references Jun Yang
2026-11-10  9:19 ` netdev-bot+sashiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox