Article View: linux.kernel.netdev
Article #27385[PATCH bpf 1/2] bpf: Don't use an unset inner transport header
From: "Chris Mason"
Date: Sat, 05 Dec 2026 12:57
Date: Sat, 05 Dec 2026 12:57
46 lines
11777 bytes
11777 bytes
A decap with bpf_skb_adjust_room() corrupts skb->transport_header if an
unset skb->inner_transport_header has wrapped around.
An unset inner transport header is in front of skb->data, so
bpf_skb_net_hdr_pop() resets it. But its offset wraps around if the skb is
copied to a buffer with less headroom:
tcp4_gro_complete() /* fraglist: inner_transport_header
stays 0 */
skb_pp_cow_data() /* 64 bytes less headroom */
skb_headers_offset_update() /* inner_transport_header = 65472 */
bpf_skb_net_shrink()
bpf_skb_net_hdr_pop() /* doesn't reset it */
bpf_skb_clear_encap() /* copies it to transport_header */
qdisc_pkt_len_segs_init() /* SKB_DROP_REASON_SKB_BAD_GSO */
The fix used here is to treat a wrapped offset as one in front of
skb->data.
Fixes: 33be492c2e23 ("bpf: Use the inner transport header after a decap")
Cc: stable@vger.kernel.org
Signed-off-by: Chris Mason <mason@kernel.org>
---
net/core/filter.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/net/core/filter.c b/net/core/filter.c
index ea20fd2be65c0..892e20291283d 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -3456,9 +3456,12 @@ static int bpf_skb_net_hdr_pop(struct sk_buff *skb, u32 off, u32 len)
/* It was in the removed bytes or before skb->data. */
skb_set_transport_header(skb, off);
}
- /* Do not leave the inner transport header in front of @off. */
+ /*
+ * Do not leave the inner transport header in front of @off. If
+ * nobody has set it, its offset can have wrapped.
+ */
if (skb->encapsulation &&
- skb_inner_transport_offset(skb) < (int)off)
+ (s16)skb_inner_transport_offset(skb) < (int)off)
skb_set_inner_transport_header(skb, off);
}
Technical Details
Message-ID:
<20261205012513.15379-2-mason@kernel.org>Path:
mbox-mo1.pugleaf.net!news-ams.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.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-377993-linux-kernel-netdev=dewy.ruReferences:
<20261205012513.15379-1-mason@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-ams.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.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-377993-linux-kernel-netdev=dewy.ru
From: mason@kernel.org ("Chris Mason")
Newsgroups: linux.kernel.netdev
Subject: [PATCH bpf 1/2] bpf: Don't use an unset inner transport header
Date: Sat, 05 Dec 2026 07:57:27 -0500
Organization: Usenet Network
Message-ID: <20261205012513.15379-2-mason@kernel.org>
References: <20261205012513.15379-1-mason@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
logging-data="3030583"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:0RGJMaedtH7kukkCQ4+oHsT/rYM= sha256:9w7LqCl6UCsmPU2GYCW5eqaZV5MFkYG3e+EtoTZad4I=
sha1:8rfLtIVfTHVbd4CMXVVVIjhLpgA= sha256:RvPZ1JZxpghgZD206oaxh4HG6EzBPqLE68XjcOXndtM=
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 715FD117E24; Sat, 5 Dec 2026 15:58:30 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.54
X-Spam-Status: No, score=-3.54 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.14, DKIM_SIGNED=0.1,
DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
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=kernel.org
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 hzeiaYBzqG03;
Sat, 5 Dec 2026 15:58:28 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377993-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id A3595117DE6; Sat, 5 Dec 2026 15:58:19 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id 4C811315C6; Sat, 5 Dec 2026 12:58:17 +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=1796475497;
b=da74GdfQGVK5peWo4fZOxYhLiF3I8t1wSqlWvCAGsDwvTfqMwWY168B67aHkmr5yju8A
wHDExDQvysROWeJtlb2peVuX6mVTpQEn6O6mFJcv6TuRhqNI3rzONzOBKmmQqkbABM25i
xhSl3c58w45ytsPJCTDT+GXvV6Zz2MS1Q0P4aw6J6TIbu+NFBEvxa/W/+inhh3LXNUVds
qjCPlPDhA0geWQHf9jYmxtNtlVBRuXXmi6SGlXAkmM/LU/tlTP63Vb+z0lrzOSRjYSL1P
cnf0KRASAFuGtHV8LACayMbdpmoYqZABDoPj/WaU3mC3CLoSnzlQYGFx1D00X5LizDA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796475497;
h=X-Original-To:Received:Received:DKIM-Signature:Received:Received:
X-ME-Sender:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID:Received:X-Mailer:
X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:X-ThreadId:Date:
From:To:Cc:Message-Id:In-Reply-To:References:Subject:Content-Type:
Content-Transfer-Encoding;
bh=+9yAkLZHNJFRsbgrt994rwguDR8YO1hiasL1G9uwjX8=;
b=OPN1t8AgCncSpwrvDrnKhm36VdqVE6QQfXUbbwMNrXyR/ReRJBX8KzJ7f6Sx5IuqdBes
HsWxDJKfCaVE26dTSvibU5BjNYwAtaOtk5KVNpU1r76a2fhK3rpeMpKLNxw8yQUtf5nXB
/qZQCM9v/0QvB/8Yhg3JghpBlQPDI3dd1BhLtn4JEMO0eu68Nz/4/Cldt/+L9jHtvie5g
itebndWWza4Y72cv3lx5fGyIDYGOFZ91cmknnWrSdZ2j6JHsNVkP2mHUvQejXAYwvJDcx
QjANuiDWcoCk+/fneDmmj145BM4sBXmv6YqKQ+0krP66XK8wBBjaE8J4jW5Gc0rlFPw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eY0GXEv8;
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 F3203606A33F;
Sat, 5 Dec 2026 12:58:16 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eY0GXEv8
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1796475496;
b=q0A4PTTGDDIQGhGtOWeT0xulyczQ6QLawYQ6GEVhUomUuRyOhsfCDzNgyyz8GXh56zly
xTra3rQKx+K3+dhVEDWpSZan8KWf5xuZdbl5DudKfcT48umV6BK4O0X9XE88tHSNYNFWY
f90EjcKPZeOYXk6XFdrk20PuS/Rz65k2drqF7qtvGx6XnoXfC3xkwCCJtHQj9UY1FKsjS
n+TZ0h35vqv67zPKOU5s/j7b6wZPaYj2921e+0O0Cz/27rPLQuDOyrz59SHL+VCI6rDSx
vdqoPJlCUmoSdTyL/MuUm4NxtCaC4IWb9FRa+ZAK6lKREQLb1kgKobQYc1hLPKDdwqg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796475496;
h=Received:DKIM-Signature:Received:Received:X-ME-Sender:
X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID:Received:X-Mailer:
MIME-Version:X-ThreadId:Date:From:To:Cc:Message-Id:In-Reply-To:
References:Subject:Content-Type:Content-Transfer-Encoding;
bh=+9yAkLZHNJFRsbgrt994rwguDR8YO1hiasL1G9uwjX8=;
b=K0/hkeWBg6tcHiltTzx4YJidhkTVJHiHx9m/zoX7RLlels7M+hLexbnS1WRdVf5VzQj6
SwKQgVya/Yeou+QbPswl9JACgoK5Wcs8bkCnmukHx9+XpFUZoWuJpmmw+R4f2czJ+NelZ
QnQK602xJatjGUyItpNlQgNZZejofKWmwkxZmC68cGfVbpwrv03tWIduS54c6Ietazmy3
R8rHgs2S7EeJ0QAxQtWcwSNilZiC3oxdZu42ecWVrKB1GEI+ty+13ZmeyiLWxb/3/bPnr
i9pIpKuRGEk0uzr1T+N1/aVGaHnmDL2Q4J34yFY2EEhjw36nfTh+SMcTttu2b3N9PcA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eY0GXEv8;
arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature ECDSA (prime256v1))
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E373606A333;
Sat, 5 Dec 2026 12:58:16 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 490761F00A10;
Sat, 5 Dec 2026 12:58:15 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
s=k20260515; t=1796475495;
bh=+9yAkLZHNJFRsbgrt994rwguDR8YO1hiasL1G9uwjX8=;
h=Date:From:To:Cc:In-Reply-To:References:Subject;
b=eY0GXEv898MqrCHASgfENeZb4F0atYv/f1CEE8Eo5WMtiTdo4/goyPqIhl/zCSpNW
MQijOkubcmxVvrm3Ww5YDd9jadXwuUd4ybh/g6r/6g+AWvrYPL8igCxHJ28FCpm0Ep
YJ/6Z0Wp8wP3rFfBfZZQL7gvv7Z6p0AJ+78u86xpB8uZLbzqdhNR1wfzKlulVZRcNg
KsYTXEhU8mDpLrLnQocyNvjl9bGKJdxCnX2efEllogtVECyV7Q0HDWpqupefYG70L0
LIqAU/v3wO6OaW8sUKcpQWLVeCotPILQ8gozuE7s/AHv4CdJ7BsiNnTQUkR8CrpNwS
K3o4r95a2e/lA==
X-Received: from stl-compute-04.internal (stl-compute-04.internal [10.204.2.64])
by mailfauth.stl.internal (Postfix) with ESMTP id CBCFA780043;
Sat, 5 Dec 2026 07:58:14 -0500 (EST)
X-Received: from stl-imap-13 ([10.204.2.104])
by stl-compute-04.internal (MEProxy); Sat, 05 Dec 2026 07:58:14 -0500
X-ME-Sender: <xms:ZgoUaxDN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Tz1buA>
<xmx:ZgoUazMuQptYSTnAR284EVl_Fq8b4Ksu_7Bwgu_rEqpzgiNhkKsMog>
<xmx:ZgoUa2LQezCQWUnzGsXjX-1PI9aAWzq60cQpOJavEwBGg8zISATEewt4>
X-Feedback-ID: iccae4b50:Fastmail
X-Received: by mailuser.stl.internal (Postfix, from userid 501)
id 8C0E0F60088; Sat, 5 Dec 2026 07:58:14 -0500 (EST)
X-Mailer: MessagingEngine.com Webmail Interface
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
X-ThreadId: ANXq3wdZWbNF
X-Cc: eddyz87@gmail.com, memxor@gmail.com, martin.lau@linux.dev,
song@kernel.org, yonghong.song@linux.dev, jolsa@kernel.org,
emil@etsalapatis.com, ihor.solodrai@linux.dev, john.fastabend@gmail.com,
sdf@fomichev.me, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, willemb@google.com, horms@kernel.org, nhudson@akamai.com,
linux-kernel@vger.kernel.org, mason@kernel.org
X-In-Reply-To: <20261205012513.15379-1-mason@kernel.org>