Re: [PATCH] batman-adv: reject unrepresentable multicast TVLV offsets
Sven Eckelmann <[email protected]> Fri, 31 Jul 2026 21:05:22 +0200
| Newsgroups | org.open-mesh.lists.batman,org.kernel.vger.linux-kernel,org.kernel.vger.netdev |
|---|---|
| Message-ID | <4820667.LvFx2qVVIh@sven-desktop> |
--nextPart2488068.ElGaqSPkdT Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8"; protected-headers="v1" From: Sven Eckelmann <[email protected]> Date: Fri, 31 Jul 2026 21:05:22 +0200 Message-ID: <4820667.LvFx2qVVIh@sven-desktop> In-Reply-To: <178551276854.62695.15966621050711216654.b4-review@b4> MIME-Version: 1.0 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 --nextPart2488068.ElGaqSPkdT Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part. Content-Transfer-Encoding: 7Bit -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQS81G/PswftH/OW8cVND3cr0xT1ywUCamzx8gAKCRBND3cr0xT1 y8qbAQCAJpC+N8gtVp1zcu3oovIeDC71peKFSUsrUOGbgZZ34QD+NI1obkaTjFbq liSohRms8Aq8bavyjqWupQ04BcSR4Ac= =dZpi -----END PGP SIGNATURE----- --nextPart2488068.ElGaqSPkdT--