From: Antony Antony <antony@phenome.org>
To: Yan Yan <evitayan@google.com>
Cc: Antony Antony <antony@phenome.org>,
Jakub Kicinski <kuba@kernel.org>,
Steffen Klassert <steffen.klassert@secunet.com>,
Nathan Harold <nharold@google.com>,
Antony Antony <antony.antony@secunet.com>,
David Miller <davem@davemloft.net>,
Herbert Xu <herbert@gondor.apana.org.au>,
netdev@vger.kernel.org, Tobias Brunner <tobias@strongswan.org>,
Sabrina Dubroca <sd@queasysnail.net>
Subject: Re: [PATCH 0/18] pull request (net-next): ipsec-next 2026-06-12
Date: Fri, 3 Jul 2026 19:20:56 +0200 [thread overview]
Message-ID: <akfveJrtxW9yMLXK@Antony2201.local> (raw)
In-Reply-To: <CADHa2dB9e=O_thTEPo3Bwtj9qRxE0UJd_MBriC8qqrPFB+x9rw@mail.gmail.com>
Hi Yan,
thanks for testing. Would you please test on a new series?
On Thu, Jun 25, 2026 at 06:58:47PM -0700, Yan Yan wrote:
> Hi Antony,
>
> I ran the following test cases and two—4.2 and 6—are worth disucssing:
>
> 1. Mark Inheritance: Creates one SA and migrates it without
> specifying a new mark. [PASSED]
> 2. Mark Update: Creates one SA with a specific mark and migrates it
> to a new specific mark. [PASSED]
> 3. State Update Isolation: Creates two SAs differing only by mark and
> verifies that migrating one does not affect the other. [PASSED]
> 4. Mark Collision:
> 4.1 [Specific Mark] Creates two SAs differing only by mark: SA
> (mark_1) and an SA (mark_2). Verifies migrating SA (mark_1) to mark_2
> fails with EEXIST and both SAs intact. [PASSED]
> 4.2 [Wildcard Mark] Creates two SAs differing only by mark: SA
> (mark_1) and an SA (mark_none). Migrate the mark_none to mark_1.
> Expecting failure with EEXIST and both SAs intact. [FAILED: SA
> (mark_none) ends up being deleted]
> 5. Mark Mismatch:
> 5.1 Creates only a wildcard SA and verifying migration using a
> specific mark fails with ESRCH; SA intact [PASSED]
> 5.2 Creates only one SA (mark_1) and verifying migration using a
> mark_2 fails with ESRCH; SA intact [PASSED]
> 6. Mark Shadowing Failure:: Creates two SAs differing only by mark:
> the first SA (mark_1) and the second SA (mark None). Migrating the SA
> (mark_1) fails with ESRCH, two SAs remain untouched [PASSED]
>
> --------------------------------
> My questions are as follows:
>
> Regarding 4.2 I believe is a kernel bug. During the pre-migration
> collision check, the lookup for the mark_1 matches the wildcard SA
> itself first, causing the kernel to miss the collision with the
> existing specific SA with mark_1
>
> At https://github.com/antonyantony/linux/blob/migrate-state-fixes-v0/net/xfrm/xfrm_user.c#L3450
>
> x_new = xfrm_state_lookup(net, new_mark_key, &m.new_daddr, ----> BUG:
> We are looking for the existence of SA (mark_1) but SA (mark_none) is
> returned.
> um->id.spi, um->id.proto, m.new_family);
> if (x_new) {
> xfrm_state_put(x_new);
> if (x_new != x) { ----> BUG: We end up having x_new == x
> NL_SET_ERR_MSG(extack, "New SA tuple already occupied");
> err = -EEXIST;
> goto out;
> }
this should be fixed no. Would please try again?
> /* self-match via wide mark mask; not a collision */
>
> Would it be possible to traverse the entire list or create a lookup
> method for an exact match?
>
> Regarding 6. I wrote the tests as per the kernel implementation but
> I'm not sure it is intended. Intuitively, this migration should
> succeed by finding and updating the specific SA (mark_1) instead of
> failing. Is this failure considered an acceptable limit, or should we
> aim to support exact-match lookup here?
While trying to fix MIGRATE_STATE I fell into a rabbit hole:)
I realized many methods have this issue. Just never noticed, as it would be
a misconfiguration, and would likely cause operational issues rather than
crashes.
However, given that xfrm accepts multiple identical SAs differing only in mark,
a proper fix is to add __xfrm_state_locate_exact() for both spi and byaddr
lookups. This should be used in all calls from userspace.
I just send a new series.
https://patchwork.kernel.org/project/netdevbpf/patch/migrate-state-fixes-v0-1-a69e8637ba3b@secunet.com/
-antony
next prev parent reply other threads:[~2026-07-03 17:27 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-12 7:46 [PATCH 0/18] pull request (net-next): ipsec-next 2026-06-12 Steffen Klassert
2026-06-12 7:46 ` [PATCH 01/18] xfrm: cleanup error path in xfrm_add_policy() Steffen Klassert
2026-06-13 20:40 ` patchwork-bot+netdevbpf
2026-06-12 7:46 ` [PATCH 02/18] xfrm: Reject excessive values for XFRMA_TFCPAD Steffen Klassert
2026-06-12 7:46 ` [PATCH 03/18] xfrm: remove redundant assignments Steffen Klassert
2026-06-12 7:46 ` [PATCH 04/18] xfrm: add extack to xfrm_init_state Steffen Klassert
2026-06-12 7:46 ` [PATCH 05/18] xfrm: allow migration from UDP encapsulated to non-encapsulated ESP Steffen Klassert
2026-06-12 7:46 ` [PATCH 06/18] xfrm: fix NAT-related field inheritance in SA migration Steffen Klassert
2026-06-12 7:46 ` [PATCH 07/18] xfrm: rename reqid in xfrm_migrate Steffen Klassert
2026-06-12 7:46 ` [PATCH 08/18] xfrm: split xfrm_state_migrate into create and install functions Steffen Klassert
2026-06-12 7:46 ` [PATCH 09/18] xfrm: check family before comparing addresses in migrate Steffen Klassert
2026-06-12 7:46 ` [PATCH 10/18] xfrm: add state synchronization after migration Steffen Klassert
2026-06-12 7:46 ` [PATCH 11/18] xfrm: add error messages to state migration Steffen Klassert
2026-06-12 7:46 ` [PATCH 12/18] xfrm: move encap and xuo into struct xfrm_migrate Steffen Klassert
2026-06-12 7:46 ` [PATCH 13/18] xfrm: refactor XFRMA_MTIMER_THRESH validation into a helper Steffen Klassert
2026-06-12 7:46 ` [PATCH 14/18] xfrm: extract address family and selector validation helpers Steffen Klassert
2026-06-12 7:46 ` [PATCH 15/18] xfrm: make xfrm_dev_state_add xuo parameter const Steffen Klassert
2026-06-12 7:46 ` [PATCH 16/18] xfrm: add XFRM_MSG_MIGRATE_STATE for single SA migration Steffen Klassert
2026-06-12 7:46 ` [PATCH 17/18] xfrm: restrict netlink attributes for XFRM_MSG_MIGRATE_STATE Steffen Klassert
2026-06-12 7:46 ` [PATCH 18/18] xfrm: add documentation " Steffen Klassert
2026-06-13 20:15 ` [PATCH 0/18] pull request (net-next): ipsec-next 2026-06-12 Jakub Kicinski
2026-06-16 5:54 ` Antony Antony
2026-06-24 15:10 ` Antony Antony
[not found] ` <CADHa2dAtGVsph3Kq0id7QqgNdJww0Q=Z1PK+=fomVxKE-Mmvjg@mail.gmail.com>
2026-06-26 1:58 ` Yan Yan
2026-07-03 17:20 ` Antony Antony [this message]
2026-07-07 2:33 ` Yan Yan
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=akfveJrtxW9yMLXK@Antony2201.local \
--to=antony@phenome.org \
--cc=antony.antony@secunet.com \
--cc=davem@davemloft.net \
--cc=evitayan@google.com \
--cc=herbert@gondor.apana.org.au \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nharold@google.com \
--cc=sd@queasysnail.net \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.