From: Christian Langrock <hidden> Date: 2022-09-27 13:00:14
When using GSO it can happen that the wrong seq_hi is used for the last
packets before the wrap around. This can lead to double usage of a
sequence number. To avoid this, we should serialize this last GSO
packet.
Fixes: d7dbefc45cf5 ("xfrm: Add xfrm_replay_overflow functions for...")
Signed-off-by: Christian Langrock <redacted>
---
include/net/xfrm.h | 1 +
net/xfrm/xfrm_output.c | 2 +-
net/xfrm/xfrm_replay.c | 33 +++++++++++++++++++++++++++++++++
3 files changed, 35 insertions(+), 1 deletion(-)
@@ -750,6 +750,34 @@ int xfrm_replay_overflow(struct xfrm_state *x, struct sk_buff *skb)returnxfrm_replay_overflow_offload(x,skb);}++staticboolxfrm_replay_overflow_check_offload_esn(structxfrm_state*x,structsk_buff*skb)+{+structxfrm_replay_state_esn*replay_esn=x->replay_esn;+__u32oseq=replay_esn->oseq;+boolret=false;++/* We assume that this function is called with+*skb_is_gso(skb)==true+*/++if(x->type->flags&XFRM_TYPE_REPLAY_PROT){+oseq=oseq+1+skb_shinfo(skb)->gso_segs;+if(unlikely(oseq<replay_esn->oseq))+ret=true;+}++returnret;+}++boolxfrm_replay_overflow_check(structxfrm_state*x,structsk_buff*skb)+{+if(x->repl_mode==XFRM_REPLAY_MODE_ESN)+returnxfrm_replay_overflow_check_offload_esn(x,skb);++returnfalse;+}+#elseintxfrm_replay_overflow(structxfrm_state*x,structsk_buff*skb){
From: Jakub Kicinski <kuba@kernel.org> Date: 2022-09-27 14:22:59
On Tue, 27 Sep 2022 14:59:50 +0200 Christian Langrock wrote:
When using GSO it can happen that the wrong seq_hi is used for the last
packets before the wrap around. This can lead to double usage of a
sequence number. To avoid this, we should serialize this last GSO
packet.
Does not build but please wait for reviews before reposting:
net/xfrm/xfrm_replay.c:773:6: error: conflicting types for ‘xfrm_replay_overflow_check’; have ‘bool(struct xfrm_state *, struct sk_buff *)’ {aka ‘_Bool(struct xfrm_state *, struct sk_buff *)’}
773 | bool xfrm_replay_overflow_check(struct xfrm_state *x, struct sk_buff *skb)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
From: Leon Romanovsky <leon@kernel.org> Date: 2022-09-28 06:18:18
On Tue, Sep 27, 2022 at 02:59:50PM +0200, Christian Langrock wrote:
quoted hunk
When using GSO it can happen that the wrong seq_hi is used for the last
packets before the wrap around. This can lead to double usage of a
sequence number. To avoid this, we should serialize this last GSO
packet.
Fixes: d7dbefc45cf5 ("xfrm: Add xfrm_replay_overflow functions for...")
Signed-off-by: Christian Langrock <redacted>
---
include/net/xfrm.h | 1 +
net/xfrm/xfrm_output.c | 2 +-
net/xfrm/xfrm_replay.c | 33 +++++++++++++++++++++++++++++++++
3 files changed, 35 insertions(+), 1 deletion(-)
@@ -750,6 +750,34 @@ int xfrm_replay_overflow(struct xfrm_state *x, struct sk_buff *skb)returnxfrm_replay_overflow_offload(x,skb);}++staticboolxfrm_replay_overflow_check_offload_esn(structxfrm_state*x,structsk_buff*skb)+{+structxfrm_replay_state_esn*replay_esn=x->replay_esn;+__u32oseq=replay_esn->oseq;+boolret=false;++/* We assume that this function is called with+*skb_is_gso(skb)==true+*/++if(x->type->flags&XFRM_TYPE_REPLAY_PROT){+oseq=oseq+1+skb_shinfo(skb)->gso_segs;+if(unlikely(oseq<replay_esn->oseq))+ret=true;
On Tue, Sep 27, 2022 at 02:59:50PM +0200, Christian Langrock wrote:
When using GSO it can happen that the wrong seq_hi is used for the last
packets before the wrap around. This can lead to double usage of a
sequence number. To avoid this, we should serialize this last GSO
packet.
Fixes: d7dbefc45cf5 ("xfrm: Add xfrm_replay_overflow functions for...")
Signed-off-by: Christian Langrock <redacted>
Some minor nits:
This is already v3, not v2 as stated in the subject line.
Also, please explain the changes between the versions
(see 'git log' for examples).
The target tree is 'ipsec', not 'net-ipsec'.
Otherwise this is a fix for a real bug. So fix the build,
incorporate the review from Leon and send a v4.
Thanks!