🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
2 messages
2 total messages Started by Henry Martin Fri, 27 Nov 2026 06:47
[PATCH net] geneve: don't announce options that are not geneve options
#23374
Author: Henry Martin
Date: Fri, 27 Nov 2026 06:47
77 lines
13585 bytes
geneve_build_header() announces info->options_len in the wire header
unconditionally, but only copies the option bytes when the tunnel
metadata carries the geneve option flag.  With metadata of another
tunnel type (vxlan, erspan), set for example by a tc tunnel_key action,
the announced option space is never written: the packet goes out with
whatever bytes __skb_push() left in the skb headroom, and the peer can
read 4 or 12 stale kernel bytes per packet, repeatedly.

Only announce and emit options that are actually geneve options.  Other
metadata is dropped from the wire header instead of being replaced by
stale headroom bytes: the option space sizing and the GRO hint offset
now both follow the same condition as the copy.

This issue was discovered by Tencent CodeBuddy Security.

Cc: stable@vger.kernel.org
Fixes: 256c87c17c53 ("net: check tunnel option type in tunnel flags")
Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
---
 drivers/net/geneve.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index 0ab729f055ea0..dd1734b82af59 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -1231,7 +1231,7 @@ static void geneve_build_header(struct genevehdr *geneveh,
 				__be16 inner_proto)
 {
 	geneveh->ver = GENEVE_VER;
-	geneveh->opt_len = info->options_len / 4;
+	geneveh->opt_len = 0;
 	geneveh->oam = test_bit(IP_TUNNEL_OAM_BIT, info->key.tun_flags);
 	geneveh->critical = test_bit(IP_TUNNEL_CRIT_OPT_BIT,
 				     info->key.tun_flags);
@@ -1240,8 +1240,15 @@ static void geneve_build_header(struct genevehdr *geneveh,
 	geneveh->proto_type = inner_proto;
 	geneveh->rsvd2 = 0;
 
-	if (test_bit(IP_TUNNEL_GENEVE_OPT_BIT, info->key.tun_flags))
+	/* Only announce and copy options that are actually geneve
+	 * options.  Metadata of another tunnel type (vxlan, erspan)
+	 * must not go on the wire: there is nothing to copy it from,
+	 * and the option space would carry stale headroom bytes.
+	 */
+	if (test_bit(IP_TUNNEL_GENEVE_OPT_BIT, info->key.tun_flags)) {
+		geneveh->opt_len = info->options_len / 4;
 		ip_tunnel_info_opts_get(geneveh->options, info);
+	}
 }
 
 static int geneve_build_gro_hint_opt(const struct geneve_dev *geneve,
@@ -1336,7 +1343,10 @@ static int geneve_build_skb(struct dst_entry *dst, struct sk_buff *skb,
 	skb_reset_mac_header(skb);
 	skb_scrub_packet(skb, xnet);
 
-	opt_size =  info->options_len + cb->gro_hint_len;
+	if (test_bit(IP_TUNNEL_GENEVE_OPT_BIT, info->key.tun_flags))
+		opt_size = info->options_len + cb->gro_hint_len;
+	else
+		opt_size = cb->gro_hint_len;
 	min_headroom = LL_RESERVED_SPACE(dst->dev) + dst->header_len +
 		       GENEVE_BASE_HLEN + opt_size + ip_hdr_len;
 	err = skb_cow_head(skb, min_headroom);
@@ -1353,7 +1363,8 @@ static int geneve_build_skb(struct dst_entry *dst, struct sk_buff *skb,
 	geneve_build_header(gnvh, info, inner_proto);
 
 	if (cb->gro_hint_len)
-		geneve_put_gro_hint_opt(gnvh, info->options_len, &cb->gro_hint);
+		geneve_put_gro_hint_opt(gnvh, opt_size - cb->gro_hint_len,
+					&cb->gro_hint);
 
 	udp_tunnel_set_inner_protocol(skb, double_encap, inner_proto);
 	return 0;
-- 
2.39.5
Re: [PATCH net] geneve: don't announce options that are not geneve options
#23378
Author: netdev-bot+sinfo
Date: Fri, 27 Nov 2026 06:53
19 lines
8540 bytes
Hi!

This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:

 - Whether the issue was actually triggered, or is only theoretical
   (e.g. found by LLM and not proven at runtime). If it was triggered
   please include the symptoms, like the stack trace or kernel messages.

Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.

*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
-- 
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads