Re: [PATCH] batman-adv: reject unrepresentable multicast TVLV offsets
From: Sven Eckelmann
Date: Fri Jul 31 2026 - 15:09:11 EST
On Friday, 31 July 2026 17:46:08 CEST Sven Eckelmann wrote:
> >
> >
> > diff --git a/net/batman-adv/tvlv.c b/net/batman-adv/tvlv.c
> > index 5600aaf00627c..8354c62bd86a7 100644
> > --- a/net/batman-adv/tvlv.c
> > +++ b/net/batman-adv/tvlv.c
> > @@ -437,6 +437,9 @@ static int batadv_tvlv_call_handler(struct batadv_priv *bat_priv,
> > return NET_RX_SUCCESS;
> >
> > tvlv_offset = (unsigned char *)tvlv_value - skb->data;
> > + if (skb_headroom(skb) + tvlv_offset + tvlv_value_len >= U16_MAX)
> > + return -EINVAL;
> > +
>
> Just for documentation purposes:
>
> This is (skb->data - skb->head) + tvlv_offset + tvlv_value_len
>
> The calculation in skb_set_transport_header():
>
> offset = skb->data - skb->head
> offset += (tvlv_offset + tvlv_value_len)
>
> > skb_set_network_header(skb, tvlv_offset);
> > skb_set_transport_header(skb, tvlv_offset + tvlv_value_len);
> >
I've checked a little bit further and it might not be the preferred solution.
Please check Eric Dumazet's
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=d45cf1e7d7180256e17c9ce88e32e8061a7887fe
for a similar problem in IPv6. It is basically the same but without the
additional offset parameter which skb_set_transport_header_careful would need.
Regards,
Sven
Attachment:
signature.asc
Description: This is a digitally signed message part.