ice: do not report CHECKSUM_COMPLETE when an XDP program is attached
Subsystems (4)
PATCH v2 1/1 ice: do not report CHECKSUM_COMPLETE when an XDP program is attached
On E830, ice reports CHECKSUM_COMPLETE with the generic checksum (GCS) that the hardware computes over the received frame. If an XDP program changes the packet and returns XDP_PASS, that checksum no longer matches. The stack then checks the packet again in software and calls netdev_rx_csum_fault().
On Cloudflare servers, an XDP load balancer removes the encapsulation of the packets that it accepts locally. Our production traffic hits netdev_rx_csum_fault() all the time.
Do not use GCS while the VSI has an XDP program, as mlx5 has done since commit 5d0bb3bac4b9 ("net/mlx5e: XDP, Avoid checksum complete when XDP prog is loaded"). Set ICE_RX_FLAGS_RING_GCS in ice_vsi_cfg_rxq() instead of ice_vsi_alloc_rings(). The flag then follows the program when it is attached or removed, and after a VSI rebuild. Log an info message when a program is attached on a port with GCS.
E830 also sets the L3L4P and checksum error bits, so the packet gets CHECKSUM_UNNECESSARY or CHECKSUM_NONE, as on E810. For example, a zero UDP checksum over IPv6 is marked as bad and gets CHECKSUM_NONE. A zero UDP checksum over IPv4 gets CHECKSUM_UNNECESSARY, so the inner checksum is never checked, as on E810 and as on E830 before v6.15. The discussion in [3] concluded that CHECKSUM_UNNECESSARY only is the safe option with XDP for now, and that the decap case is a known problem.
Two pending series [1][2] give XDP access to the checksum status. Neither of them supports CHECKSUM_COMPLETE.
Tested on an E830 with an XDP program that removes 16 bytes of UDP payload with bpf_xdp_adjust_head() and returns XDP_PASS:
- Without this patch, the changed packets got CHECKSUM_COMPLETE, and the stack called netdev_rx_csum_fault() 368512 times.
- With it, they got CHECKSUM_UNNECESSARY, and there were no calls.
- Plain UDP got CHECKSUM_UNNECESSARY while the program was attached, also after ethtool -L rebuilt the VSI, and CHECKSUM_COMPLETE again after it was removed.
On an E810, which has no GCS, drivers/net/xdp.py, ping.py and hw/csum.py give the same results with and without this patch.
---
Changes in v2:
- Set ICE_RX_FLAGS_RING_GCS in ice_vsi_cfg_rxq() instead of reading rx_ring->xdp_prog for each packet in ice_rx_csum() (Alexander Duyck).
- Log an info message when a program is attached on a port with GCS (Alexander Duyck).
- Drop the paragraph about the two reads of rx_ring->xdp_prog. It does not apply any more.
- Move the test results into the commit message.
- Drop the Acked-by of Maciej Fijalkowski, because the code changed.
- v1: https://lore.kernel.org/all/[email protected]/
The E810 tests ran on net. The E830 tests ran on v6.18.65 with this patch applied, on 8086:12d2 with fw.mgmt 7.9.5 and DDP ICE COMMS 1.3.63.0. Without the patch, 164150 changed IPv4 packets and 154671 changed IPv6 packets got CHECKSUM_COMPLETE in 2 s each.
drivers/net/ethernet/intel/ice/ice_base.c | 7 +++++++ drivers/net/ethernet/intel/ice/ice_lib.c | 3 --- drivers/net/ethernet/intel/ice/ice_main.c | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/ice/ice_base.c +7 -0
@@ -705,6 +705,13 @@ static int ice_vsi_cfg_rxq(struct ice_rx_ring *ring) } } +/* XDP can change the frame and make the GCS value wrong */ +if (ice_is_feature_supported (ring->vsi->back,ICE_F_GCS ) && + !ice_is_xdp_ena_vsi (ring->vsi)) + ring->flags |=ICE_RX_FLAGS_RING_GCS ; +else + ring->flags &= ~ICE_RX_FLAGS_RING_GCS ; + ring->xdp.data =NULL ; err =ice_setup_rx_ctx (ring);if (err) {
drivers/net/ethernet/intel/ice/ice_lib.c +0 -3
@@ -1532,9 +1532,6 @@ static int ice_vsi_alloc_rings(struct ice_vsi *vsi) ring->count = vsi->num_rx_desc; ring->cached_phctime = pf->ptp.cached_phc_time; -if (ice_is_feature_supported (pf,ICE_F_GCS )) - ring->flags |=ICE_RX_FLAGS_RING_GCS ; -WRITE_ONCE (vsi->rx_rings[i], ring); }
drivers/net/ethernet/intel/ice/ice_main.c +2 -0
@@ -2944,6 +2944,8 @@ ice_xdp_setup_prog(struct ice_vsi *vsi, struct bpf_prog *prog, } }xdp_features_set_redirect_target (vsi->netdev, true); +if (ice_is_feature_supported (vsi->back,ICE_F_GCS )) +netdev_info (vsi->netdev,"XDP program attached, Rx CHECKSUM_COMPLETE disabled\n" ); }else if (ice_is_xdp_ena_vsi (vsi) && !prog) {xdp_features_clear_redirect_target (vsi->netdev); xdp_ring_err =ice_destroy_xdp_rings (vsi,ICE_XDP_CFG_FULL );
base-commit: cc7fe6e741730fef549e484379281736d32746f0
Signature · 1 line
2.56.0
From: Tianyi Gao <[email protected]>
Date: Wed, 25 Nov 2026 09:52:01 +0000
Quoted 5 lines
On E830, ice reports
CHECKSUM_COMPLETEwith the generic checksum (GCS) that the hardware computes over the received frame. If an XDP program changes the packet and returnsXDP_PASS, that checksum no longer matches. The stack then checks the packet again in software and callsnetdev_rx_csum_fault().
Thanks,
Olek
Quoted 9 lines
Changes in v2:
- SetICE_RX_FLAGS_RING_GCSinice_vsi_cfg_rxq()instead of readingrx_ring->xdp_progfor each packet inice_rx_csum()(Alexander Duyck).
- Log an info message when a program is attached on a port with GCS (Alexander Duyck).
- Drop the paragraph about the two reads ofrx_ring->xdp_prog. It does not apply any more.
- Move the test results into the commit message.
- Drop the Acked-by of Maciej Fijalkowski, because the code changed.
My ack was meant to say: let us get the behavior aligned to mlx5 and given that there is pending work regarding checksum capabilities in XDP, Alexander's concerns are meant to be addressed at -next kernel candidates.
If code has changed *so much* why have you kept the Suggested-by tag from Jesse?
Quoted 1 line
Quoted 3 lines · Maciej Fijalkowski
My ack was meant to say: let us get the behavior aligned to mlx5 and given that there is pending work regarding checksum capabilities in XDP, Alexander's concerns are meant to be addressed at -next kernel candidates.
Thanks for clarifying, and sorry for dropping it. I was not sure if the ack still applied after the change moved to the control path. The behavior in v2 is the same as in v1, aligned to mlx5. If you are fine with v2, could you send your Acked-by again, or could I just bring it back if there is a v3?
Quoted 2 lines
If code has changed *so much* why have you kept the Suggested-by tag from Jesse?
The Suggested-by tag is mainly about what to fix rather than the code. But Jesse and I also discussed the code itself before I sent v1 and v2, so I kept it.
Thanks,
Tianyi
Quoted 10 lines · Tianyi Gao
Quoted 3 lines · Maciej Fijalkowski
My ack was meant to say: let us get the behavior aligned to mlx5 and given that there is pending work regarding checksum capabilities in XDP, Alexander's concerns are meant to be addressed at -next kernel candidates.
Thanks for clarifying, and sorry for dropping it. I was not sure if the ack still applied after the change moved to the control path. The behavior in v2 is the same as in v1, aligned to mlx5. If you are fine with v2, could you send your Acked-by again, or could I just bring it back if there is a v3?
no need for a respin just for that, both of you could reply with the tag (you already received it, so you have the power too :))
and a tag from myself, based on feedback by Maciej and Olek:
Quoted 11 lines
Quoted 3 lines
If code has changed *so much* why have you kept the Suggested-by tag from Jesse?
The Suggested-by tag is mainly about what to fix rather than the code. But Jesse and I also discussed the code itself before I sent v1 and v2, so I kept it.
Thanks,
Tianyi
Quoted 10 lines · Tianyi Gao
On E830, ice reports
CHECKSUM_COMPLETEwith the generic checksum (GCS) that the hardware computes over the received frame. If an XDP program changes the packet and returnsXDP_PASS, that checksum no longer matches. The stack then checks the packet again in software and callsnetdev_rx_csum_fault().On Cloudflare servers, an XDP load balancer removes the encapsulation of the packets that it accepts locally. Our production traffic hits
netdev_rx_csum_fault()all the time.
Thank you for addressing my comments. My biggest concern as this point is still this opens up potential holes for exploitation. While it doesn't appear to directly enable an exploit it is one of those things that can be stacked to allow for someone to take advantage of things. I would rank it up there with the e1000e jumbo frames packet truncation issue/fix from back in the day (CVE-2009-4536/CVE-2009-1385).
I will give this my "Reviewed-by" as there is some level of XDP-based shooting yourself in the foot required to trigger this. However, that said my suggestion would be to be very careful stripping headers like this as it could lead to future exploits.
Tianyi Gao
Acked-by Maciej FijalkowskiThanks for the reviews and the ack, Olek, Przemek and Alex.
Also adding back Maciej's ack, as Przemek suggested:
Quoted 3 lines · Alexander Duyck
I would rank it up there with the e1000e jumbo frames packet truncation issue/fix from back in the day (CVE-2009-4536/CVE-2009-1385).
Thank you for the pointer. It is interesting to see how it was exploited back then.
As you said, this case needs an XDP program that changes the packet and still returns XDP_PASS. So far I have not noticed a way that it can be stacked with other bugs, but I will keep it in mind.
Thanks,
Tianyi