mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH ipsec 0/2] xfrm: fix state lifetimes in xfrm_migrate()
@ 2026-10-31  4:14 Cen Zhang
  2026-10-31  4:14 ` [PATCH ipsec 1/2] xfrm: keep old state references until migration deletion completes Cen Zhang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Cen Zhang @ 2026-10-31  4:14 UTC (permalink / raw)
  To: steffen.klassert, herbert, davem, edumazet, kuba, pabeni
  Cc: horms, netdev, linux-kernel, baijiaju1990, jjzuming, zzzccc427

xfrm_migrate() keeps the old states in x_cur[] and their successors in
x_new[], but it does not hold a reference to every state it later
deletes. An SA with a hard lifetime can expire and be freed by the timer
and the state GC in that window, and the following xfrm_state_delete()
takes the lock of freed memory:

  1/2 The success path drops the lookup references of the old states
      before it deletes them. Delete them first.

  2/2 xfrm_state_migrate() returns the published successor without a
      caller reference, so the rollback deletes states it does not
      hold. Take that reference before publishing and drop it after the
      migration commits or rolls back.

Both windows date back to the initial migration support and are reached
by XFRM_MSG_MIGRATE and PF_KEY's SADB_X_MIGRATE.

Cen Zhang (2):
  xfrm: keep old state references until migration deletion completes
  xfrm: hold migrated states through rollback

 net/xfrm/xfrm_policy.c | 7 +++++--
 net/xfrm/xfrm_state.c  | 6 +++++-
 2 files changed, 10 insertions(+), 3 deletions(-)

---

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

end of thread, other threads:[~2026-10-31  4:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-31  4:14 [PATCH ipsec 0/2] xfrm: fix state lifetimes in xfrm_migrate() Cen Zhang
2026-10-31  4:14 ` [PATCH ipsec 1/2] xfrm: keep old state references until migration deletion completes Cen Zhang
2026-10-31  4:14 ` [PATCH ipsec 2/2] xfrm: hold migrated states through rollback Cen Zhang
2026-10-31  4:18 ` [PATCH ipsec 0/2] xfrm: fix state lifetimes in xfrm_migrate() netdev-bot+sinfo

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

all inboxes | Powered by JetHome®