From: Antony Antony <antony.antony@secunet.com>
To: Steffen Klassert <steffen.klassert@secunet.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>, David Ahern <dsahern@kernel.org>,
Antony Antony <antony.antony@secunet.com>,
Jamal Hadi Salim <hadi@cyberus.ca>, Shuah Khan <shuah@kernel.org>
Cc: Sabrina Dubroca <sd@queasysnail.net>, <netdev@vger.kernel.org>,
Yan Yan <evitayan@google.com>,
Tobias Brunner <tobias@strongswan.org>,
Florian Westphal <fw@strlen.de>,
<linux-kselftest@vger.kernel.org>, <linux-doc@vger.kernel.org>,
Sashiko <sashiko-bot@kernel.org>,
Antony Antony <antony@phenome.org>
Subject: [PATCH ipsec 0/8] xfrm: state: exact mark/mask match for control-plane SA lookups
Date: Fri, 3 Jul 2026 20:53:44 +0200 [thread overview]
Message-ID: <migrate-state-fixes-v0-0-a69e8637ba3b@secunet.com> (raw)
While looking into a XFRM_MSG_MIGRATE_STATE issue reported by Sashiko,
we found the underlying problem generalizes: xfrm allows multiple SAs
to coexist for the same (SPI, daddr, proto) differing only in mark,
and every control-plane operation that resolves "which SA" - get,
delete, update, get_ae, new_ae, expire, migrate - uses the same
wildcard mark match the data path needs. A broader-mask SA can
silently shadow a more specific one:
# ip xfrm state add ... spi 0x1000 mark 1 mask 1 (SA_target)
# ip xfrm state add ... spi 0x1000 mark 0 mask 0
(SA_decoy, catch-all, added after -> bucket head)
# ip xfrm state delete dst ... proto esp spi 0x1000 mark 1 mask 1
-> deletes SA_decoy; SA_target survives, untouched
xfrm policy had the same bug, fixed in commit 4f47e8ab6ab7
("xfrm: policy: match with both mark and mask on user interfaces").
Control-plane lookups need an exact mark/mask match; the wildcard
match stays for the data path and state_add only.
This series applies that fix across every affected method,
not just XFRM_MSG_MIGRATE_STATE.
More examples in the attached self tests.
This series not fixing likely isusses PF_KEY. As it
is no more receiving non critical fixes.
---
Antony Antony (8):
xfrm: state: exact mark/mask match for SPI-keyed control-plane SA lookups
xfrm: state: exact mark/mask match for by-address control-plane SA lookups
selftests: net: xfrm_state: add mark shadowing tests for state lookups
xfrm: fix use-after-free of migrated state in xfrm_do_migrate_state()
xfrm: fix hw offload state leak on xfrm_do_migrate_state() error path
xfrm: include mark in MIGRATE_STATE SA collision check
xfrm: pass extack through to xfrm_init_replay() from xfrm_init_state()
docs: xfrm: include mark in XFRM_MSG_MIGRATE_STATE EEXIST tuple
.../networking/xfrm/xfrm_migrate_state.rst | 20 ++--
include/net/xfrm.h | 5 +-
net/ipv6/xfrm6_input.c | 2 +-
net/xfrm/xfrm_state.c | 109 +++++++++++++----
net/xfrm/xfrm_user.c | 49 +++++---
tools/testing/selftests/net/xfrm_state.sh | 130 ++++++++++++++++++++-
6 files changed, 262 insertions(+), 53 deletions(-)
---
base-commit: 226f4a490d1a938fc838d8f8c46a4eca864c0d78
change-id: migrate-state-fixes-063ee0342611
Best regards,
--
Antony Antony <antony.antony@secunet.com>
next reply other threads:[~2026-07-03 18:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-03 18:53 Antony Antony [this message]
2026-07-03 17:07 ` [PATCH ipsec 1/8] xfrm: state: exact mark/mask match for SPI-keyed control-plane SA lookups Antony Antony
2026-07-03 17:07 ` [PATCH ipsec 2/8] xfrm: state: exact mark/mask match for by-address " Antony Antony
2026-07-03 17:07 ` [PATCH ipsec 3/8] selftests: net: xfrm_state: add mark shadowing tests for state lookups Antony Antony
2026-07-03 17:08 ` [PATCH ipsec 4/8] xfrm: fix use-after-free of migrated state in xfrm_do_migrate_state() Antony Antony
2026-07-03 17:08 ` [PATCH ipsec 5/8] xfrm: fix hw offload state leak on xfrm_do_migrate_state() error path Antony Antony
2026-07-03 17:08 ` [PATCH ipsec 6/8] xfrm: include mark in MIGRATE_STATE SA collision check Antony Antony
2026-07-03 17:08 ` [PATCH ipsec 7/8] xfrm: pass extack through to xfrm_init_replay() from xfrm_init_state() Antony Antony
2026-07-03 17:09 ` [PATCH ipsec 8/8] docs: xfrm: include mark in XFRM_MSG_MIGRATE_STATE EEXIST tuple Antony Antony
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=migrate-state-fixes-v0-0-a69e8637ba3b@secunet.com \
--to=antony.antony@secunet.com \
--cc=antony@phenome.org \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=evitayan@google.com \
--cc=fw@strlen.de \
--cc=hadi@cyberus.ca \
--cc=herbert@gondor.apana.org.au \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sashiko-bot@kernel.org \
--cc=sd@queasysnail.net \
--cc=shuah@kernel.org \
--cc=steffen.klassert@secunet.com \
--cc=tobias@strongswan.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