From: Steffen Klassert <steffen.klassert@secunet.com>
To: Cosmin Ratiu <cratiu@nvidia.com>
Cc: <netdev@vger.kernel.org>, <ipsec@lists.linux.dev>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>, Shannon Nelson <sln@onemain.com>,
Tariq Toukan <tariqt@nvidia.com>
Subject: Re: [PATCH ipsec] xfrm: replay: Fix late packet handling with ESN crypto offload
Date: Fri, 20 Nov 2026 09:14:00 +0100 [thread overview]
Message-ID: <awABSJrYIhEIbSZY@gauss4> (raw)
In-Reply-To: <20261110133821.2548903-1-cratiu@nvidia.com>
On Tue, Nov 10, 2026 at 03:38:21PM +0200, Cosmin Ratiu wrote:
> xfrm_replay_seqhi() guesses seq_hi for a given ingress seq per RFC 4303
> section A2.2. Packets with seq < bottom are interpreted as being ahead
> and the function returns the next seq_hi. xfrm_replay_check_esn() redoes
> the same computation and defers to the ICV check.
>
> On SW crypto, such packets then fail the ICV check and are dropped,
> unless they're actual packets ~2^32 in the future (very unlikely).
>
> But on crypto offload, the ICV check already happened in HW and isn't
> repeated. xfrm_replay_advance_esn() then increments replay_esn->seq_hi.
>
> The problem becomes visible when the HW state is renewed (e.g. bond
> failover or mlx5 mid-sequence ESN state update). The newly offloaded SA
> carries the wrong seq_hi and completely breaks ingress since all future
> packets fail ICV.
>
> This was verified on b2b ConnectX NICs, with an 'iperf3 -P 2' test over
> a pair of SAs over a bond device in active-backup mode.
> After ~10s of traffic at ~10 Gbps, replay_esn->seq_hi was ~2.5M due to
> the two streams sharing the ESN state.
> Forcing a bond failover on both sides breaks traffic permanently.
>
> Fix this by dropping packets up to 2^31 before the replay window for
> crypto offload, since the SW seq_hi guess cannot be validated. Packets
> up to 2^31 ahead are accepted as new, same as old code. A burst loss of
> more than 2^31 packets now stalls the SA (previously up to 2^32-wsize).
>
> SW crypto is unaffected.
>
> Fixes: 50bd870a9e5c ("xfrm: Add ESN support for IPSec HW offload")
> Signed-off-by: Cosmin Ratiu <cratiu@nvidia.com>
Applied, thanks a lot Cosmin!
prev parent reply other threads:[~2026-11-20 8:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 13:38 [PATCH ipsec] xfrm: replay: Fix late packet handling with ESN crypto offload Cosmin Ratiu
2026-11-20 8:14 ` Steffen Klassert [this message]
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=awABSJrYIhEIbSZY@gauss4 \
--to=steffen.klassert@secunet.com \
--cc=cratiu@nvidia.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=horms@kernel.org \
--cc=ipsec@lists.linux.dev \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sln@onemain.com \
--cc=tariqt@nvidia.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