From: Steffen Klassert <steffen.klassert@secunet.com>
To: Yan Yan <evitayan@google.com>
Cc: <netdev@vger.kernel.org>,
Herbert Xu <herbert@gondor.apana.org.au>,
<antony.antony@secunet.com>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, <pabeni@redhat.com>,
<horms@kernel.org>, <saakashkumar@marvell.com>,
<akamluddin@marvell.com>, Nathan Harold <nharold@google.com>,
<greg@kroah.com>
Subject: Re: [REGRESSION] Discussion on "xfrm: Duplicate SPI Handling"
Date: Mon, 2 Feb 2026 10:44:43 +0100 [thread overview]
Message-ID: <aYByCz-DWi2VZMy-@secunet.com> (raw)
In-Reply-To: <CADHa2dChQ=4UVY5X5Ad=jryGRCBPQ37Z_Sw60-6h6h_EcUFG9g@mail.gmail.com>
On Wed, Jan 28, 2026 at 04:43:06PM +0800, Yan Yan wrote:
> Hi all,
>
> I am writing because unfortunately commit: 94f39804d891 ("xfrm:
> Duplicate SPI Handling") has caused a regression in the Android OS, so
> we would like to gain some context to help determine next steps. The
> issue is caused by the new requirement for global SPI uniqueness
> during allocation. Based on our review of RFC 4301 and the previous
> review history, we would like to highlight a few concerns:
>
> 1. Regression on Android:
> This change breaks production behavior in Android, which uses
> XFRM_MSG_ALLOCSPI to create larval SAs for both directions. Since RFC
> 4301 allows duplicate outbound SPIs, and larval SAs are often created
> before direction or selectors are finalized, the allocator must remain
> permissive (at least in our current design).
> This also aligns with a concern Herbert Xu raised during the initial
> review regarding compatibility:
> > "It's also dangerous to unilaterally do this since existing deployments
> > could rely on the old behaviour. You'd need to add a toggle for
> > compatibility."
Indeed, it was...
> 2. Inbound SPI uniqueness should not be a hard requirement:
> The justification for enforcing global SPI uniqueness often cites the
> statement in RFC 4301, Section 4.1, that for unicast traffic, the SPI
> "by itself suffices to specify an SA." However, we don’t think this
> means inbound SPI uniqueness is a hard requirement because of the two
> following reasons:
>
> – Another statement implies that SPI uniqueness is just an
> implementation choice:
> > "Each entry in the SA Database (SAD) MUST
> > indicate whether the SA lookup makes use of the destination IP address, or the
> > destination and source IP addresses, in addition to the SPI."
When reading RFC 4301, I'd interpret this as 'The SA
must indicate whether it is unicast or multicast'.
>
> – There is a "Longest Match" mandate which makes SPI uniqueness unnecessary:
> > "For each inbound, IPsec-protected packet, an implementation MUST
> > conduct its search of the SAD such that it finds the entry that
> > matches the 'longest' SA identifier. In this context, if two or more
> > SAD entries match based on the SPI value, then the entry that also
> > matches based on destination address... is the 'longest' match."
This is meant for multicast SAs, we don't support multicast SAs.
> 3. Further clarification on the specific problem being addressed would
> be helpful. The "real-world" problem this commit intends to fix
> remains unclear. The patch mentions:
> > "This behavior causes inconsistencies during SPI lookups for inbound packets.
> > Since the lookup may return an arbitrary SA among those with the same SPI,
> > packet processing can fail, resulting in packet drops."
>
> However, Linux kernel lookups using the triplet (SPI, Protocol, Daddr)
> are deterministic. The lookup will not return an "arbitrary" SA
> because the destination address is used to disambiguate the state.
That was how RFC 2401 did it:
A security association is uniquely identified by a triple consisting
of a Security Parameter Index (SPI), an IP Destination Address, and a
security protocol (AH or ESP) identifier.
That was obsoleted by RFC RFC 4301 saying the SPI alone identifies
the SA for unicast traffic.
Unfortunately our implementation is somewhat between RFC 2401
and RFC 4301. There was no clear cut to support both versions.
Maybe it is time to do this now and implement RFC 4301
with a toggle to fallback to RFC 2401. This would avoid
these kind of problems in the future, at least.
> As Antony suggested, this change may cater to SPI-only hardware
> indexing. If that is the case, we are concerned about applying such
> hardware-specific limits to the software stack, especially if the
> behavior is not opt-in, as it appears to require an overly-narrow
> reading of the RFC 4301.
>
> Given these concerns, would it be possible to discuss a revert or,
> alternatively, could further context be provided regarding the
> specific real-world problem this commit was intended to address? Once
> the underlying issue is clearly defined, we can work together to find
> a backward-compatible solution that satisfies all requirements.
Here we end up with the question about the default behaviour,
should the default be RFC 4301 or RFC 2401?
next prev parent reply other threads:[~2026-02-02 9:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-28 8:43 [REGRESSION] Discussion on "xfrm: Duplicate SPI Handling" Yan Yan
2026-02-02 9:44 ` Steffen Klassert [this message]
2026-02-02 14:27 ` Antony Antony
2026-02-09 3:03 ` Yan Yan
2026-02-09 19:05 ` Nathan Harold
2026-02-10 10:17 ` Tobias Brunner
2026-02-18 4:36 ` Yan Yan
2026-02-18 8:41 ` Tobias Brunner
2026-02-24 23:53 ` Nathan Harold
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=aYByCz-DWi2VZMy-@secunet.com \
--to=steffen.klassert@secunet.com \
--cc=akamluddin@marvell.com \
--cc=antony.antony@secunet.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=evitayan@google.com \
--cc=greg@kroah.com \
--cc=herbert@gondor.apana.org.au \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nharold@google.com \
--cc=pabeni@redhat.com \
--cc=saakashkumar@marvell.com \
/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