Skip to content

Commit f015b90

Browse files
Sebastian Andrzej Siewiorklassert
authored andcommitted
xfrm: Linearize the skb after offloading if needed.
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: 7785bba ("esp: Add a software GRO codepath") Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent 842665a commit f015b90

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

net/ipv4/esp4_offload.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,9 @@ static int esp_xmit(struct xfrm_state *x, struct sk_buff *skb, netdev_features_
340340

341341
secpath_reset(skb);
342342

343+
if (skb_needs_linearize(skb, skb->dev->features) &&
344+
__skb_linearize(skb))
345+
return -ENOMEM;
343346
return 0;
344347
}
345348

net/ipv6/esp6_offload.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,9 @@ static int esp6_xmit(struct xfrm_state *x, struct sk_buff *skb, netdev_features
374374

375375
secpath_reset(skb);
376376

377+
if (skb_needs_linearize(skb, skb->dev->features) &&
378+
__skb_linearize(skb))
379+
return -ENOMEM;
377380
return 0;
378381
}
379382

0 commit comments

Comments
 (0)