]> git.dujemihanovic.xyz Git - linux.git/commitdiff
xfrm: Linearize the skb after offloading if needed.
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Wed, 14 Jun 2023 10:02:02 +0000 (12:02 +0200)
committerSteffen Klassert <steffen.klassert@secunet.com>
Fri, 16 Jun 2023 08:29:50 +0000 (10:29 +0200)
With offloading enabled, esp_xmit() gets invoked very late, from within
validate_xmit_xfrm() which is after validate_xmit_skb() validates and
linearizes the skb if the underlying device does not support fragments.

esp_output_tail() may add a fragment to the skb while adding the auth
tag/ IV. Devices without the proper support will then send skb->data
points to with the correct length so the packet will have garbage at the
end. A pcap sniffer will claim that the proper data has been sent since
it parses the skb properly.

It is not affected with INET_ESP_OFFLOAD disabled.

Linearize the skb after offloading if the sending hardware requires it.
It was tested on v4, v6 has been adopted.

Fixes: 7785bba299a8d ("esp: Add a software GRO codepath")
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
net/ipv4/esp4_offload.c
net/ipv6/esp6_offload.c

index 3969fa805679cd25f373526f5a7d0b7be7172040..ee848be59e65a7d8f90a6bd09c61732152fad68c 100644 (file)
@@ -340,6 +340,9 @@ static int esp_xmit(struct xfrm_state *x, struct sk_buff *skb,  netdev_features_
 
        secpath_reset(skb);
 
+       if (skb_needs_linearize(skb, skb->dev->features) &&
+           __skb_linearize(skb))
+               return -ENOMEM;
        return 0;
 }
 
index 75c02992c520f94e1f53de89ea6463acc842c331..7723402689973f236ae96e159eddc6ea2ea09559 100644 (file)
@@ -374,6 +374,9 @@ static int esp6_xmit(struct xfrm_state *x, struct sk_buff *skb,  netdev_features
 
        secpath_reset(skb);
 
+       if (skb_needs_linearize(skb, skb->dev->features) &&
+           __skb_linearize(skb))
+               return -ENOMEM;
        return 0;
 }