From: Sven Eckelmann The tvlv_len of a unicast TVLV packet covers the TVLV header and the TVLV content. It is only 16 bit wide. batadv_tvlv_unicast_send() stores the sum of both in it without a check. A content of more than 65531 bytes results in a packet with a truncated tvlv_len. The callers are expected to limit the content to a valid size. But a packet which can't be parsed by the receiver must never be sent. Drop it in batadv_tvlv_unicast_send() when a caller missed this limit. Fixes: ef26157747d4 ("batman-adv: tvlv - basic infrastructure") Reported-by: Sashiko Closes: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261030135105.2555887-1-sw%40simonwunderlich.de?part=14 Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/tvlv.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/net/batman-adv/tvlv.c b/net/batman-adv/tvlv.c index aa8dbaa5ef78..f6cb4c889ad7 100644 --- a/net/batman-adv/tvlv.c +++ b/net/batman-adv/tvlv.c @@ -729,6 +729,9 @@ void batadv_tvlv_handler_unregister(struct batadv_priv *bat_priv, * @version: tvlv version * @tvlv_value: tvlv content * @tvlv_value_len: tvlv content length + * + * The packet is not sent when the tvlv header and the tvlv content don't fit + * in the 16 bit tvlv_len of the unicast tvlv packet. */ void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, const u8 *src, const u8 *dst, u8 type, u8 version, @@ -742,12 +745,14 @@ void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, const u8 *src, unsigned int tvlv_len; struct sk_buff *skb; + tvlv_len = sizeof(*tvlv_hdr) + tvlv_value_len; + if (tvlv_len > U16_MAX) + return; + orig_node = batadv_orig_hash_find(bat_priv, dst); if (!orig_node) return; - tvlv_len = sizeof(*tvlv_hdr) + tvlv_value_len; - skb = netdev_alloc_skb_ip_align(NULL, ETH_HLEN + hdr_len + tvlv_len); if (!skb) goto out; -- 2.47.3