All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH ipsec] xfrm: BEET mode doesn't support fragments for inner packets
@ 2021-03-19 10:27 Xin Long
  2021-03-25  8:44 ` Steffen Klassert
  0 siblings, 1 reply; 2+ messages in thread
From: Xin Long @ 2021-03-19 10:27 UTC (permalink / raw)
  To: netdev; +Cc: kuba, Sabrina Dubroca, Steffen Klassert, David S. Miller

BEET mode replaces the IP(6) Headers with new IP(6) Headers when sending
packets. However, when it's a fragment before the replacement, currently
kernel keeps the fragment flag and replace the address field then encaps
it with ESP. It would cause in RX side the fragments to get reassembled
before decapping with ESP, which is incorrect.

In Xiumei's testing, these fragments went over an xfrm interface and got
encapped with ESP in the device driver, and the traffic was broken.

I don't have a good way to fix it, but only to warn this out in dmesg.

Reported-by: Xiumei Mu <xmu@redhat.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/xfrm/xfrm_output.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c
index b81ca11..e4cb0ff 100644
--- a/net/xfrm/xfrm_output.c
+++ b/net/xfrm/xfrm_output.c
@@ -660,6 +660,12 @@ static int xfrm4_extract_output(struct xfrm_state *x, struct sk_buff *skb)
 {
 	int err;
 
+	if (x->outer_mode.encap == XFRM_MODE_BEET &&
+	    ip_is_fragment(ip_hdr(skb))) {
+		net_warn_ratelimited("BEET mode doesn't support inner IPv4 fragments\n");
+		return -EAFNOSUPPORT;
+	}
+
 	err = xfrm4_tunnel_check_size(skb);
 	if (err)
 		return err;
@@ -705,8 +711,15 @@ static int xfrm6_tunnel_check_size(struct sk_buff *skb)
 static int xfrm6_extract_output(struct xfrm_state *x, struct sk_buff *skb)
 {
 #if IS_ENABLED(CONFIG_IPV6)
+	unsigned int ptr = 0;
 	int err;
 
+	if (x->outer_mode.encap == XFRM_MODE_BEET &&
+	    ipv6_find_hdr(skb, &ptr, NEXTHDR_FRAGMENT, NULL, NULL) >= 0) {
+		net_warn_ratelimited("BEET mode doesn't support inner IPv6 fragments\n");
+		return -EAFNOSUPPORT;
+	}
+
 	err = xfrm6_tunnel_check_size(skb);
 	if (err)
 		return err;
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH ipsec] xfrm: BEET mode doesn't support fragments for inner packets
  2021-03-19 10:27 [PATCH ipsec] xfrm: BEET mode doesn't support fragments for inner packets Xin Long
@ 2021-03-25  8:44 ` Steffen Klassert
  0 siblings, 0 replies; 2+ messages in thread
From: Steffen Klassert @ 2021-03-25  8:44 UTC (permalink / raw)
  To: Xin Long; +Cc: netdev, kuba, Sabrina Dubroca, David S. Miller

On Fri, Mar 19, 2021 at 06:27:58PM +0800, Xin Long wrote:
> BEET mode replaces the IP(6) Headers with new IP(6) Headers when sending
> packets. However, when it's a fragment before the replacement, currently
> kernel keeps the fragment flag and replace the address field then encaps
> it with ESP. It would cause in RX side the fragments to get reassembled
> before decapping with ESP, which is incorrect.
> 
> In Xiumei's testing, these fragments went over an xfrm interface and got
> encapped with ESP in the device driver, and the traffic was broken.
> 
> I don't have a good way to fix it, but only to warn this out in dmesg.

Looks like a protocol bug. BEET mode never made it to a standard...

> 
> Reported-by: Xiumei Mu <xmu@redhat.com>
> Signed-off-by: Xin Long <lucien.xin@gmail.com>

Applied, thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-25  8:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-19 10:27 [PATCH ipsec] xfrm: BEET mode doesn't support fragments for inner packets Xin Long
2021-03-25  8:44 ` Steffen Klassert

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.