Netdev List
 help / color / mirror / Atom feed
* [PATCH net] geneve: fix out-of-bounds read in the DF inherit path
@ 2026-11-25 23:55 Xiang Mei
  2026-12-04 10:50 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Xiang Mei @ 2026-11-25 23:55 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni
  Cc: netdev, linux-kernel, stable, co+80332c538f1d1a9d, Xiang Mei

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@vger.kernel.org
Fixes: a025fb5f49ad ("geneve: Allow configuration of DF behaviour")
Reported-by: co+80332c538f1d1a9d@bugs.sh
Signed-off-by: Xiang Mei <xmei5@asu.edu>
---
 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


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

* Re: [PATCH net] geneve: fix out-of-bounds read in the DF inherit path
  2026-11-25 23:55 [PATCH net] geneve: fix out-of-bounds read in the DF inherit path Xiang Mei
@ 2026-12-04 10:50 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-12-04 10:50 UTC (permalink / raw)
  To: Xiang Mei
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel, stable, co+80332c538f1d1a9d

Hello:

This patch was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Wed, 25 Nov 2026 16:55:24 -0700 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - [net] geneve: fix out-of-bounds read in the DF inherit path
    https://git.kernel.org/netdev/net-next/c/e5ba10df689a

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2026-12-04 10:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 23:55 [PATCH net] geneve: fix out-of-bounds read in the DF inherit path Xiang Mei
2026-12-04 10:50 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox