[PATCH net] geneve: fix out-of-bounds read in the DF inherit path

From: Xiang Mei

Date: Wed Nov 25 2026 - 18:55:37 EST


The GENEVE_DF_INHERIT branch of geneve_xmit_skb() decides the inner
packet is IPv4 from skb_eth_hdr(skb)->h_proto and then reads
ip_hdr(skb)->frag_off, but skb_vlan_inet_prepare() only pulled an IPv4
header if skb_protocol(skb, true) is ETH_P_IP. For AF_PACKET/SOCK_RAW the
two are independent: a 14-byte frame with h_proto 0x0800 sent with
sll_protocol ETH_P_ARP passes the pull with only ETH_HLEN and the DF test
reads 6 bytes past skb->tail. The stale tailroom bit is copied into the
outer IPv4 DF bit on the wire, leaking one bit of slab memory per packet
to a user holding CAP_NET_ADMIN/CAP_NET_RAW in a user namespace. With
inner_proto_inherit there is no inner Ethernet header at all, so the
h_proto test is wrong there too.

The leak was observed. A PoC plants a known byte in a freed
skbuff_small_head object and reads it back one bit per probe from the
outer DF bit:

planted=0xff recovered=0xff MATCH
planted=0xa5 recovered=0xa5 MATCH
planted=0x5a recovered=0x5a MATCH
planted=0xc3 recovered=0xc3 MATCH
phase B: 8/8 planted bytes recovered exactly (8 bits each)

With this patch every probe reads 0 (1/8, only the 0x00 pattern), while
the df=set/unset controls are unchanged.

Test skb_protocol(skb, true), the value the pull was keyed on, as the
TOS/TTL inheritance already does via ip_tunnel_get_dsfield() and
ip_tunnel_get_ttl().

Cc: stable@xxxxxxxxxxxxxxx
Fixes: a025fb5f49ad ("geneve: Allow configuration of DF behaviour")
Reported-by: co+80332c538f1d1a9d@xxxxxxx
Signed-off-by: Xiang Mei <xmei5@xxxxxxx>
---
drivers/net/geneve.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index 0ab729f055ea..74e9509598cf 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -1471,11 +1471,11 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
if (cfg->df == GENEVE_DF_SET) {
df = htons(IP_DF);
} else if (cfg->df == GENEVE_DF_INHERIT) {
- struct ethhdr *eth = skb_eth_hdr(skb);
+ __be16 inner_proto = skb_protocol(skb, true);

- if (ntohs(eth->h_proto) == ETH_P_IPV6) {
+ if (inner_proto == htons(ETH_P_IPV6)) {
df = htons(IP_DF);
- } else if (ntohs(eth->h_proto) == ETH_P_IP) {
+ } else if (inner_proto == htons(ETH_P_IP)) {
struct iphdr *iph = ip_hdr(skb);

if (iph->frag_off & htons(IP_DF))
--
2.43.0