Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] igb: missing IGB_TS_HDR_LEN room in 2 KiB build_skb buffers
  with XDP
--

commit 91c56c1d76e1bd0d76622dd294c28474abad9f0e
Author: Tjerk Kusters <[email protected]>

igb: do not let XDP frames span more than one Rx buffer

This commit limits RLPML and VMOLR to the configured maximum frame size while
XDP is attached, accounts for the inline Rx timestamp header when checking if
a frame fits in one Rx buffer, and prevents rx-all or legacy-rx changes from
bypassing those limits.

Link: https://lore.kernel.org/all/[email protected]/

> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c 
> b/drivers/net/ethernet/intel/igb/igb_main.c
> index ce91dda00ec0e..5f1a5e2240e64 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c

[ ... ]

> @@ -2886,6 +2946,27 @@ static int igb_setup_tc(struct net_device *dev, enum 
> tc_setup_type type,
>       }
>  }
>  
> +/* Check that a frame fits in one Rx buffer together with the inline Rx
> + * timestamp header, for the buffer size igb_set_rx_buffer_len() selects.
> + * The ring flags are only updated when the rings are configured, so they
> + * are not used here. For build_skb rings the frame is limited to
> + * IGB_MAX_FRAME_BUILD_SKB, which is below the 2 KiB hardware buffer size
> + * even with the header.
> + */
> +static bool igb_xdp_frame_fits(struct igb_adapter *adapter, int max_frame)
> +{
> +#if (PAGE_SIZE < 8192)
> +     if (!(adapter->flags & IGB_FLAG_RX_LEGACY)) {
> +             if (max_frame <= IGB_MAX_FRAME_BUILD_SKB &&
> +                 !IGB_2K_TOO_SMALL_WITH_PADDING)
> +                     return true;

[Severity: High]
Can a frame with an inline Rx timestamp overflow into skb_shared_info on a
2 KiB build_skb buffer?

Although IGB_MAX_FRAME_BUILD_SKB + IGB_TS_HDR_LEN fits inside the 2048-byte
hardware buffer size in SRRCTL, DMA on a build_skb buffer starts at
IGB_SKB_PAD and must leave SKB_DATA_ALIGN(sizeof(struct skb_shared_info))
bytes at the end of the 2 KiB slice:

drivers/net/ethernet/intel/igb/igb.h:igb_skb_pad() {
    ...
        else
                rx_buf_len = IGB_RXBUFFER_1536;

        /* if needed make room for NET_IP_ALIGN */
        rx_buf_len -= NET_IP_ALIGN;

        return igb_compute_pad(rx_buf_len);
}

Because igb_skb_pad() sets IGB_SKB_PAD to
SKB_WITH_OVERHEAD(IGB_RXBUFFER_2048) - IGB_MAX_FRAME_BUILD_SKB without
reserving IGB_TS_HDR_LEN (16 bytes), only IGB_MAX_FRAME_BUILD_SKB bytes are
available between the DMA start offset and skb_shared_info.

When hardware Rx timestamping is enabled (E1000_RXDADV_STAT_TSIP) and RLPML
or VMOLR allows frames up to max_frame_size (or IGB_MAX_FRAME_BUILD_SKB), the
MAC strips the 4-byte FCS and prepends the 16-byte timestamp, writing
wire_len + 12 bytes from IGB_SKB_PAD.  A frame with wire_len between
IGB_MAX_FRAME_BUILD_SKB - 11 and IGB_MAX_FRAME_BUILD_SKB (for example at MTU
1500..1510) pushes xdp.data_end up to 12 bytes past
SKB_WITH_OVERHEAD(IGB_RXBUFFER_2048).  On XDP_PASS, igb_build_skb() ->
napi_build_skb() zeroes skb_shared_info over the end of the payload and
__skb_put() advances skb->tail past skb->end, triggering skb_over_panic() on
a later skb_put() or skb_copy(); on XDP_TX or XDP_REDIRECT,
xdp_update_frame_from_buff() hits XDP_WARN and drops the frame.

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=1

Reply via email to