Re: [PATCH net] net: tcp: Update the type of scaling_ratio

From: Eric Dumazet
Date: Mon May 06 2024 - 08:43:16 EST


On Mon, May 6, 2024 at 2:35 PM Eric Dumazet <edumazet@xxxxxxxxxx> wrote:
>
> On Mon, May 6, 2024 at 2:04 PM Horatiu Vultur
> <horatiu.vultur@xxxxxxxxxxxxx> wrote:
> >
> > It was noticed the following issue that sometimes the scaling_ratio was
> > getting a value of 0, meaning that window space was having a value of 0,
> > so then the tcp connection was stopping.
> > The reason why the scaling_ratio was getting a value of 0 is because
> > when it was calculated, it was truncated from a u64 to a u8. So for
> > example if it scaling_ratio was supposed to be 256 it was getting a
> > value of 0.
> > The fix consists in chaning the type of scaling_ratio from u8 to u16.
> >
> > Fixes: dfa2f0483360 ("tcp: get rid of sysctl_tcp_adv_win_scale")
> > Signed-off-by: Horatiu Vultur <horatiu.vultur@xxxxxxxxxxxxx>
> > ---
>
> This is a wrong patch. We need to fix the root cause instead.
>
> By definition, skb->len / skb->truesize must be < 1
>
> If not, a driver is lying to us and this is quite bad.
>
> Please take a look at the following patch for a real fix.
>
> 4ce62d5b2f7aecd4900e7d6115588ad7f9acccca net: usb: ax88179_178a: stop
> lying about skb->truesize

Remaining buggy drivers would be these USB drivers:

drivers/net/usb/aqc111.c:1154: new_skb->truesize =
SKB_TRUESIZE(new_skb->len);
drivers/net/usb/smsc75xx.c:2237:
skb->truesize = size + sizeof(struct sk_buff);
drivers/net/usb/smsc75xx.c:2256:
ax_skb->truesize = size + sizeof(struct sk_buff);
drivers/net/usb/smsc95xx.c:1873:
skb->truesize = size + sizeof(struct sk_buff);
drivers/net/usb/smsc95xx.c:1891:
ax_skb->truesize = size + sizeof(struct sk_buff);
drivers/net/usb/sr9700.c:424: skb->truesize = len +
sizeof(struct sk_buff);
drivers/net/usb/sr9700.c:436: sr_skb->truesize = len +
sizeof(struct sk_buff);