When the 64-bit ESN counter overflows, xfrm_replay_overflow_offload_esn() rejects the packet and rolls back the stored counter. It decrements replay_esn->oseq even though only the local oseq has advanced, which can later induce a reuse of the last sequence number and the corresponding AES-GCM nonce. Both IPv4 and IPv6 are affected, yet, processing about 2^64 packets under a single key is required to trigger this bug, which is highly unlikely in regular use cases. Leave replay_esn->oseq unchanged on overflow. Keep the decrement of replay_esn->oseq_hi to undo its earlier increment. Fixes: d7dbefc45cf5 ("xfrm: Add xfrm_replay_overflow functions for offloading") Cc: stable@vger.kernel.org Signed-off-by: Jérémy Jean --- net/xfrm/xfrm_replay.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/xfrm/xfrm_replay.c b/net/xfrm/xfrm_replay.c index 9394953247ab9..01504e5b1ad41 100644 --- a/net/xfrm/xfrm_replay.c +++ b/net/xfrm/xfrm_replay.c @@ -721,7 +721,6 @@ static int xfrm_replay_overflow_offload_esn(struct xfrm_state *x, struct sk_buff xo->seq.hi = oseq_hi; } if (replay_esn->oseq_hi == 0) { - replay_esn->oseq--; replay_esn->oseq_hi--; xfrm_audit_state_replay_overflow(x, skb); err = -EOVERFLOW; -- 2.47.3