hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/net/xfrm/xfrm_replay.c
....@@ -1,21 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * xfrm_replay.c - xfrm replay detection, derived from xfrm_state.c.
34 *
45 * Copyright (C) 2010 secunet Security Networks AG
56 * Copyright (C) 2010 Steffen Klassert <steffen.klassert@secunet.com>
6
- *
7
- * This program is free software; you can redistribute it and/or modify it
8
- * under the terms and conditions of the GNU General Public License,
9
- * version 2, as published by the Free Software Foundation.
10
- *
11
- * This program is distributed in the hope it will be useful, but WITHOUT
12
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14
- * more details.
15
- *
16
- * You should have received a copy of the GNU General Public License along with
17
- * this program; if not, write to the Free Software Foundation, Inc.,
18
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
197 */
208
219 #include <linux/export.h>
....@@ -101,7 +89,8 @@
10189 if (x->type->flags & XFRM_TYPE_REPLAY_PROT) {
10290 XFRM_SKB_CB(skb)->seq.output.low = ++x->replay.oseq;
10391 XFRM_SKB_CB(skb)->seq.output.hi = 0;
104
- if (unlikely(x->replay.oseq == 0)) {
92
+ if (unlikely(x->replay.oseq == 0) &&
93
+ !(x->props.extra_flags & XFRM_SA_XFLAG_OSEQ_MAY_WRAP)) {
10594 x->replay.oseq--;
10695 xfrm_audit_state_replay_overflow(x, skb);
10796 err = -EOVERFLOW;
....@@ -180,7 +169,8 @@
180169 if (x->type->flags & XFRM_TYPE_REPLAY_PROT) {
181170 XFRM_SKB_CB(skb)->seq.output.low = ++replay_esn->oseq;
182171 XFRM_SKB_CB(skb)->seq.output.hi = 0;
183
- if (unlikely(replay_esn->oseq == 0)) {
172
+ if (unlikely(replay_esn->oseq == 0) &&
173
+ !(x->props.extra_flags & XFRM_SA_XFLAG_OSEQ_MAY_WRAP)) {
184174 replay_esn->oseq--;
185175 xfrm_audit_state_replay_overflow(x, skb);
186176 err = -EOVERFLOW;
....@@ -584,7 +574,8 @@
584574
585575 XFRM_SKB_CB(skb)->seq.output.hi = 0;
586576 xo->seq.hi = 0;
587
- if (unlikely(oseq < x->replay.oseq)) {
577
+ if (unlikely(oseq < x->replay.oseq) &&
578
+ !(x->props.extra_flags & XFRM_SA_XFLAG_OSEQ_MAY_WRAP)) {
588579 xfrm_audit_state_replay_overflow(x, skb);
589580 err = -EOVERFLOW;
590581
....@@ -623,7 +614,8 @@
623614
624615 XFRM_SKB_CB(skb)->seq.output.hi = 0;
625616 xo->seq.hi = 0;
626
- if (unlikely(oseq < replay_esn->oseq)) {
617
+ if (unlikely(oseq < replay_esn->oseq) &&
618
+ !(x->props.extra_flags & XFRM_SA_XFLAG_OSEQ_MAY_WRAP)) {
627619 xfrm_audit_state_replay_overflow(x, skb);
628620 err = -EOVERFLOW;
629621
....@@ -665,7 +657,7 @@
665657 oseq += skb_shinfo(skb)->gso_segs;
666658 }
667659
668
- if (unlikely(oseq < replay_esn->oseq)) {
660
+ if (unlikely(xo->seq.low < replay_esn->oseq)) {
669661 XFRM_SKB_CB(skb)->seq.output.hi = ++oseq_hi;
670662 xo->seq.hi = oseq_hi;
671663 replay_esn->oseq_hi = oseq_hi;