Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Medium] netxen: TX fragment hardware limit bypass due to unstripped 0-length 
fragments
--

commit daf1ad3622d94edcda5ee23317b335a0a1a7de23
Author: Josef Bacik <[email protected]>

netxen: use pskb_may_pull() to pull excess TX frags into the head

This commit replaces a direct call to __pskb_pull_tail() with pskb_may_pull()
in the netxen driver's transmit path to pull excess fragments into the head.

> diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c 
> b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
> index 67d9bf69f8f29..202deb64ddefb 100644
> --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
> +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
> @@ -2045,7 +2045,7 @@ netxen_nic_xmit_frame(struct sk_buff *skb, struct 
> net_device *netdev)
>                       delta += skb_frag_size(frag);
>               }
>  
> -             if (!__pskb_pull_tail(skb, delta))
> +             if (!pskb_may_pull(skb, skb_headlen(skb) + delta))

[Severity: Medium]
Does this change bypass the hardware limit for TX fragments by failing to
strip 0-length fragments?

If an SKB is transmitted with more than 14 fragments and the first excess
fragments are 0-length, delta will be 0. 

The original code handled this by calling __pskb_pull_tail() which strips
0-length fragments even when the length to eat is 0:

net/core/skbuff.c:__pskb_pull_tail() {
        ...
        int size = skb_frag_size(&skb_shinfo(skb)->frags[i]);

        if (size <= eat) {
                skb_frag_unref(skb, i);
                eat -= size;
        } else {
        ...
}

Because 0 <= 0 evaluates to true, the 0-length fragment is successfully
removed and nr_frags is reduced.

However, pskb_may_pull() returns true immediately without modifying the
SKB when requested to pull skb_headlen(skb) + 0 bytes.

This leaves the SKB with frag_count > NETXEN_MAX_FRAGS_PER_TX (14). Will
the driver then program a descriptor chain with more fragments than the
firmware supports?

>                       goto drop_packet;
>  
>               frag_count = 1 + skb_shinfo(skb)->nr_frags;

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/20261007-b4-pskb-pull-tail-drivers-v1-0-9512b0fb9...@toxicpanda.com?part=7

Reply via email to