All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] batman-adv: reject unrepresentable multicast TVLV offsets
@ 2026-07-31 13:52 David Lee
  2026-07-31 15:46 ` Sven Eckelmann
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: David Lee @ 2026-07-31 13:52 UTC (permalink / raw)
  To: marek.lindner, sw, antonio, sven
  Cc: David Lee, Kyle Zeng, Dominik 'Disconnect3d' Czarnota,
	b.a.t.m.a.n, linux-kernel

The network and transport header fields in struct sk_buff are 16-bit
offsets from skb->head, and U16_MAX is reserved as the unset transport
header value. batadv_tvlv_call_handler() sets both fields without checking
that the end of a received multicast TVLV is representable.

A sufficiently large TVLV therefore wraps the transport header offset.
skb_network_header_len() then returns a bogus large length, allowing
batadv_mcast_forw_packet() to access memory beyond the skb data.

Reject multicast TVLVs whose absolute end offset cannot be represented
before changing either header field.

Fixes: 07afe1ba288c ("batman-adv: mcast: implement multicast packet reception and forwarding")
Bug found and triaged by OpenAI Security Research and 
validated by Trail of Bits.

Assisted-by: Codex:gpt-5.6-sol gpt-5.5-cyber
Signed-off-by: Kyle Zeng <kylebot@openai.com>
---
Trail of Bits has a reproducer for this bug that triggers a
KASAN use-after-free and can share if needed.

 net/batman-adv/tvlv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/batman-adv/tvlv.c b/net/batman-adv/tvlv.c
index 1c9fb2198..5e9d0e2dd 100644
--- a/net/batman-adv/tvlv.c
+++ b/net/batman-adv/tvlv.c
@@ -433,6 +433,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;
+
 		skb_set_network_header(skb, tvlv_offset);
 		skb_set_transport_header(skb, tvlv_offset + tvlv_value_len);
 
-- 
2.53.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-08-01  9:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-31 13:52 [PATCH] batman-adv: reject unrepresentable multicast TVLV offsets David Lee
2026-07-31 15:46 ` Sven Eckelmann
2026-07-31 19:05   ` Sven Eckelmann
2026-07-31 15:46 ` Sven Eckelmann
2026-08-01  9:55   ` Sven Eckelmann
2026-08-01  9:54 ` [PATCH] batman-adv: reject unrepresentable multicast TVLV offsets (+ b4 check signed-off-problems) Sven Eckelmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.