🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #22894

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

#22894
From: Yuansheng Yang
Date: Thu, 26 Nov 2026 03:44
68 lines
13121 bytes
vxlan_xmit_one() calls skb_vlan_inet_prepare() to pull the inner network
header into linear memory before assigning old_iph = ip_hdr(skb).  That
helper checks skb->protocol (skipping VLAN tags) and only pulls an IPv4 or
IPv6 header when the inner protocol is ETH_P_IP or ETH_P_IPV6.

However, the VXLAN_DF_INHERIT branch inspects eth_hdr(skb)->h_proto
before reading old_iph->frag_off.  With AF_PACKET/SOCK_RAW, eth->h_proto
and skb->protocol are independent: a 14-byte Ethernet frame with
h_proto set to ETH_P_IP and sll_protocol set to ETH_P_ARP passes
skb_vlan_inet_prepare() with only ETH_HLEN bytes pulled, leaving old_iph
pointing at skb->tail.  Reading old_iph->frag_off then accesses 6 bytes
past skb->tail in uninitialized tailroom and copies one bit into the
outer IPv4 DF bit.

Using eth_hdr(skb)->h_proto also fails to inherit DF for VLAN-tagged
packets and reads past the nonexistent Ethernet header on VXLAN-GPE
packets without Ethernet encapsulation.

Use skb_protocol(skb, true) to match skb_vlan_inet_prepare(), as the
TTL, DSCP and flowlabel inheritance helpers already do.

Discovered by manual code inspection following the sibling geneve
DF-inherit fix, with Gemini assisting in path verification and preparing
this patch and changelog.  Verified by static analysis and compile
testing only; the out-of-bounds read was not triggered or tested at
runtime.

Fixes: b4d3069783bc ("vxlan: Allow configuration of DF behaviour")
Cc: stable@vger.kernel.org
Signed-off-by: Yuansheng Yang <0xbeac@gmail.com>
---
Sibling geneve fix on netdev/lkml:
  https://lore.kernel.org/lkml/20261125235524.4139551-1-xmei5@asu.edu/

Testing: drivers/net/vxlan/vxlan_core.o compiled with W=1 on x86_64
(GCC 15.2.0, CONFIG_VXLAN=y, CONFIG_KASAN=y) with no warnings or errors;
git apply --check passes.  Not dynamically tested; no runtime reproducer
was executed.

Checked against net.git HEAD ef3e21c61baa (whose vxlan_core.c matches
the base-commit blob below).

 drivers/net/vxlan/vxlan_core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
index d11028b37472..76a1828111ea 100644
--- a/drivers/net/vxlan/vxlan_core.c
+++ b/drivers/net/vxlan/vxlan_core.c
@@ -2551,10 +2551,10 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
 			if (cfg->df == VXLAN_DF_SET) {
 				df = htons(IP_DF);
 			} else if (cfg->df == VXLAN_DF_INHERIT) {
-				struct ethhdr *eth = eth_hdr(skb);
+				__be16 inner_proto = skb_protocol(skb, true);
 
-				if (ntohs(eth->h_proto) == ETH_P_IPV6 ||
-				    (ntohs(eth->h_proto) == ETH_P_IP &&
+				if (inner_proto == htons(ETH_P_IPV6) ||
+				    (inner_proto == htons(ETH_P_IP) &&
 				     old_iph->frag_off & htons(IP_DF)))
 					df = htons(IP_DF);
 			}
-- 
2.43.0

base-commit: c710c654b8a3c92b34e38740dc17c29daf5b222e
Technical Details
Message-ID: <20261126034412.2799912-1-0xbeac@gmail.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371868-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371868-linux-kernel-netdev=dewy.ru
From: 0xbeac@gmail.com (Yuansheng Yang)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] vxlan: fix out-of-bounds read in DF inherit path
Date: Thu, 26 Nov 2026 11:44:12 +0800
Organization: Usenet Network
Message-ID: <20261126034412.2799912-1-0xbeac@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="374348"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:QjcY/Ngr+JIdqfbasA4XWsFKGwg= sha256:FkNrO+84EQGmXdHE3J++c8mwyMx23qlkE8LiTILaFaQ=
	sha1:fCCZATSoZhpB1Ha2JoYlP9c2/Sw= sha256:p6kmIwM+Lr0uHlJAcQVLyZjGiM7r7tf3xdg8rNuc6Rw=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id E2BE2125EB0; Thu, 26 Nov 2026 06:44:47 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.149
X-Spam-Status: No, score=-3.149 tagged_above=-9999 required=6.31
	tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id iQ02WVEUcsgj;
	Thu, 26 Nov 2026 06:44:44 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-371868-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 07E34125EAE; Thu, 26 Nov 2026 06:44:33 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 0164437862; Thu, 26 Nov 2026 03:44:29 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795664669;
	b=I9OlauyznqRirRgXTwLWo+azuuMcLmlpumr+yJHMcbf3/lU8Amhz6Aqn5rTRLZpJbpi6
	 ZaXBRPB0z+mqQmLsbZQOGVQbouniAcuow5N9smZBzC6OjfW233PWRzTxDWaIW9gyzqJAi
	 6qBG19Eayl6ssHYUGBYq2v5oNb9bzsQG2MLQwJAytV7eQ2iXBoHXRWmpXRG0AM0+1JhN8
	 CmS5WDfTDzli10da9rpv/Ek2OT/w/BNL9X4E109c4927GPLaENQ6J7dG0Fd0dHQ+axre5
	 zz1pGdaNQoLsqYR+KRV10tGYlDIeUgZgyLDbRjICmLa23vEi4VRWzUu++53DatQ/9qQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795664669;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding;
	bh=tIBO2BUTqLnTN0WSYteEPUPQWOKHzyHrEAfQKEoCCvQ=;
	b=ZIVJD4IycuXv4Gs+o/ROxCgc7pbjbIpc1MrKNKwaB8gdQQXP5pUnd13xzzRd1BT9ffWd
	 ZzIeSRPnBn6h9q+Zu3JbzMGA7BUvHVsRPZib1rQzw0jq4crsbpkmEmAnltWuRsXTHMRI4
	 LecsvoBVIa1UayDaFI96qsBWlYf4FhplEwLMOJE9XnK+5dCS0H5/AaI+7ObvNc/NvnHKm
	 U8hO182kV0DjmDgq2WfaLcYxN62hnIRugsZKbtdEjQA7kBKCDt3h774KriV9t4VTcSgAk
	 JXr7qYJYr6uWLvwFE/RcRLKkwA06L6bOUZ/U315nmrpdTpOjfH6hA91A//335LVFTCw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=rDvPnH5Q;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id B7229606A32C;
	Thu, 26 Nov 2026 03:44:29 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=rDvPnH5Q
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.171
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795664663;
	b=Ne0jmzNW9Y7qJx3GEolUHKmCwl5pvpZxIBeyMkJjkFghuoUsVq/E5V47iWVWz4VzDnW4
	 yTkeOeoa4YRZieWlsPmXMFHNHlQ7fqb5PmHld9EPCMWQSMAg+IXvhufU8rpf3o2+g+rnd
	 TZSF0MkmnzcopfKmp6MgkATC07NVvuDTwy5fmpWaoc+a7ashpApCMNV5/Jvvkqm2DrCEl
	 VRkzA5gF1e/2/OFwyeK6GRVDJXAeiC/SE5VtTXlDipY3sSSnvdqqnKaln+uBwi5ha5lxQ
	 2YYj3DsOqJNaTS6B2f1mIYvOocxgXCzb29Uje7jl0aTGGz7FEm85OE5QvC50qwxeSfg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795664663;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding;
	bh=tIBO2BUTqLnTN0WSYteEPUPQWOKHzyHrEAfQKEoCCvQ=;
	b=abHppgt7zX+MQAOyhGtilzyukcglM6XDvwA5EKz+g1FYINRHmRCuhsuUlrxSL9BnNveT
	 PbIH1agje04IEC2xxXPYT4tMGIY0RSB8MWRF2gPzgBo0P3W9D2Y7crDCDLBpyExr9yXmO
	 q5GoculhXWcndE7kOZW5/2mFoMnrIktbxARyKFmXlDDq88f+6lUD4JDEX5ubxTrIcudRd
	 qUXxInMMlF7hQLDzEzo2ZhTctNzfYjFFRrDGEAgzsxktDudiR+Og1VNH5KUSY6tusJyBh
	 R0Fu2k0tFu6aTaT39hco081wauKCoyugROrtUzawmi03ulSgjpTHWAdhril+fZH+z0g==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=rDvPnH5Q;
	arc=none smtp.remote-ip=209.85.210.171
X-Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 84E0E606A326
	for <netdev@vger.kernel.org>; Thu, 26 Nov 2026 03:44:23 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 84E0E606A326
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-89d6bd67045so3081969b3a.0
        for <netdev@vger.kernel.org>; Wed, 25 Nov 2026 19:44:23 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1795664663; x=1796269463; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:message-id:date:subject:cc
         :to:from:from:to:cc:subject:date:message-id:reply-to:content-type;
        bh=tIBO2BUTqLnTN0WSYteEPUPQWOKHzyHrEAfQKEoCCvQ=;
        b=rDvPnH5QZMdTGsxXLFq6yBa7Rae/o6kaBkovnkvKsXmGe+R1gObeMRg9eJ7DZextSf
         v0pu4vnn4mRlgoU6jghwZTDX/RLN9uOmFdfbzO7uliWdv7xYcGwvN5etlimmXZZirZB8
         VSK+kvmQqw9Fs3zaKw2sBgpALl3gkmhzcStG7rxn4TIqeQzGSsPQyVAij4fuVfiSsrRq
         uHsA8uzDtnWEAmTB7EY28Uw2aVHQdQxmY1yEh+11WwiXJgufemNN2GGobDz3O3QvFRYm
         4juINxCbiQueqb7MEW/H+wfN8zw+K5AgwAwYHdZi/tQ61cBAGTFCRMwdVtyU9vG1Tos8
         eIQA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1795664663; x=1796269463;
        h=content-transfer-encoding:mime-version:message-id:date:subject:cc
         :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=tIBO2BUTqLnTN0WSYteEPUPQWOKHzyHrEAfQKEoCCvQ=;
        b=WFUkKMYZ83HAsFp6vI47KmyPmquTySsb/pRf7nuHRGa9Nxwp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2BkRZF
X-Received: by 2002:a05:6a00:27aa:b0:89e:37b1:b820 with SMTP id d2e1a72fcca58-8c8792bebbcmr12357321b3a.2.1795664662746;
        Wed, 25 Nov 2026 19:44:22 -0800 (PST)
X-Received: from dell ([58.246.183.50])
        by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8c87343f83dsm10018512b3a.39.2026.11.25.19.44.17
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Wed, 25 Nov 2026 19:44:22 -0800 (PST)
X-Cc: netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
X-Mailer: git-send-email 2.53.0
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list