From: Jun Yang <juny24602@gmail.com>
To: steffen.klassert@secunet.com, herbert@gondor.apana.org.au
Cc: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org,
shinta.sugimoto@ericsson.com, yoshfuji@linux-ipv6.org,
nakam@linux-ipv6.org, netdev@vger.kernel.org,
Jun Yang <junvyyang@tencent.com>,
stable@kernel.org, TencentOS Corvus AI <corvus@tencent.com>
Subject: [PATCH net] xfrm: delete migrated old states before dropping their references
Date: Fri, 6 Nov 2026 17:02:56 +0800 [thread overview]
Message-ID: <20261106090300.29203-1-juny24602@gmail.com> (raw)
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
next reply other threads:[~2026-11-06 9:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 9:02 Jun Yang [this message]
2026-11-10 9:19 ` [PATCH net] xfrm: delete migrated old states before dropping their references netdev-bot+sashiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261106090300.29203-1-juny24602@gmail.com \
--to=juny24602@gmail.com \
--cc=corvus@tencent.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=horms@kernel.org \
--cc=junvyyang@tencent.com \
--cc=kuba@kernel.org \
--cc=nakam@linux-ipv6.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shinta.sugimoto@ericsson.com \
--cc=stable@kernel.org \
--cc=steffen.klassert@secunet.com \
--cc=yoshfuji@linux-ipv6.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox