🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #4376

[PATCH bpf-next v2 12/43] bpf: Pull the inner header for End.DT6 in End.BPF

#4376
From: Alexei Starovoitov
Date: Sat, 17 Oct 2026 16:37
52 lines
10368 bytes
From: Josef Bacik <josef@toxicpanda.com>

bpf_lwt_seg6_action(SEG6_LOCAL_ACTION_END_DT6) pulls the outer headers off
the packet and hands it to seg6_lookup_nexthop(), which reads the inner
IPv6 header at skb->data. Nothing says that this header is in the head of
the skb, or that there is one. If the head ends with the outer headers,
the route is looked up for whatever lies behind the head, and the packet
is dropped or leaves by the wrong route. If the program then pushes an SRH
with SEG6_LOCAL_ACTION_END_B6, seg6_do_srh_inline() pulls an IPv6 header
off a head which has none, and __skb_pull() hits its BUG(): the kernel
panics on a packet from the network.

GRO pulls the inner header of a plain IPv6 in IPv6 packet into the head. It
takes a packet which GRO does not look into that far, one with a fragment
header in front of the inner header for example, or a device without GRO,
and a driver which leaves the inner header in a fragment.

Make sure of the inner header together with the outer ones. The program
goes on behind an error of the helper, so do it before the packet is
changed. A pull which fails can still have moved the head, so look for the
SRH again.

Fixes: 486cdf21583e ("bpf: add End.DT6 action to bpf_lwt_seg6_action helper")
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
---
 net/core/filter.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/core/filter.c b/net/core/filter.c
index a62f3decf1e2..6fbe0cea2140 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -7066,9 +7066,14 @@ BPF_CALL_4(bpf_lwt_seg6_action, struct sk_buff *, skb,
 
 		if (ipv6_find_hdr(skb, &hdroff, IPPROTO_IPV6, NULL, NULL) < 0)
 			return -EBADMSG;
-		if (!pskb_pull(skb, hdroff))
+		/* As long as nothing has been changed, the program goes on */
+		if (!pskb_may_pull(skb, hdroff + sizeof(struct ipv6hdr))) {
+			/* but the head may have moved */
+			bpf_update_srh_state(skb);
 			return -EBADMSG;
+		}
 
+		__skb_pull(skb, hdroff);
 		skb_postpull_rcsum(skb, skb_network_header(skb), hdroff);
 		skb_reset_network_header(skb);
 		skb_reset_transport_header(skb);
-- 
2.55.0
Technical Details
Message-ID: <20261017163745.3341787-13-alexei.starovoitov@gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-347786-linux-kernel-netdev=dewy.ru
References: <20261017163745.3341787-1-alexei.starovoitov@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-347786-linux-kernel-netdev=dewy.ru
From: alexei.starovoitov@gmail.com (Alexei Starovoitov)
Newsgroups: linux.kernel.netdev
Subject: [PATCH bpf-next v2 12/43] bpf: Pull the inner header for End.DT6 in End.BPF
Date: Sat, 17 Oct 2026 16:37:14 +0000
Organization: Usenet Network
Message-ID: <20261017163745.3341787-13-alexei.starovoitov@gmail.com>
References: <20261017163745.3341787-1-alexei.starovoitov@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3088273"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:SqTpShUV0V7n4EYpamJ7tNpOGgA= sha256:QC91BfV2jtXFiIXQ1EGs49QXGwbmhNg5CG8wGEWjGII=
	sha1:8m7ntM7UBvdpmpDZVA8Qoza9ILY= sha256:5tzS7PCnVMKTzm1hQeRhCeIO9XEH52s+aE8lZC2qkyY=
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 8F3761106E4; Sat, 17 Oct 2026 19:54:09 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, 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.25,
	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 ZNni2QQ8np6f;
	Sat, 17 Oct 2026 19:54:06 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-347786-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 906E7110726; Sat, 17 Oct 2026 19:53:57 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by sea.lore.kernel.org (Postfix) with ESMTP id 362DA62E6F; Sat, 17 Oct 2026 16:39:04 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 07B202D73A6;
	Sat, 17 Oct 2026 16:39:04 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XIhLPMV9"
X-Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id C78D93939A2
	for <netdev@vger.kernel.org>; Sat, 17 Oct 2026 16:39:02 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.50
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1792255143; cv=none; b=Z9g4Q/UVUNC1FZvHD+lhjoz8szT+KD3SNlpmM2N1VNUz95A6AwR6ycy4P/2wjwPcRrkEc7fJrmcOleK5WQCaYn+zD4FUQNHtvp2nlhXFJEBHe0N/UUofGysDuyZf8mMf0MfQT01hIwfd4ksmtX8PxTVdOstMK0p3tN7zBbgdeYY=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1792255143; c=relaxed/simple;
	bh=7AEfMtx9Kcanp4UjTKPB/YCQKJtXbAs74T3H5GqGVMQ=;
	h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:
	 MIME-Version; b=Y3LKB6K3qhvjzNVq0fm2y4Tg2nKIZGFe+Ul6LjvK4qmRSnYFHMNP3YDibIvNW6+9R/zYLMrk9c2QOHnHGe6h9/owoRbyz5KO1SXwXW4S3b9ePpoMAMyO1+j64SvFUCTZT3bTEes90cVg+PeftdAjZuvq3rWvAxIstC2EcsZ3ES4=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XIhLPMV9; arc=none smtp.client-ip=209.85.216.50
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-pj1-f50.google.com with SMTP id 98e67ed59e1d1-3ac7842c17dso534296a91.3
        for <netdev@vger.kernel.org>; Sat, 17 Oct 2026 09:39:02 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20251104; t=1792255142; x=1792859942; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=Ez6MSD+AceaDu7vNZmXph72FgmoMN2SxdaCBTXkP/s8=;
        b=XIhLPMV9nTah1Avqt9+FxtWJpByFhsKvh8JwSlObvY9dz6EfccjvSNjrI5t2O9xkzc
         EU+Ei3G70iG0GY9AWpZlzTY4zpJNK+dsTg9dWHMfB36LzR0aDNIUA3SkFp014LZsCy0b
         Gjiz+op010r0jD9RqAJbvAiehrlTG+zVoGG3oUR5UfbnC/S989APpF5TJ/CwufeJd4AE
         bFNgy42wDaz6YoevXsuc077rB2Wyrf1xfYp2H6RoUS+/rhbSQPvj6JKirZcPzOnDruHU
         ddh+t0I9v70JzRjBr9WkW9D5uDHo8k36kJOKcNfVf87uJAZWOPXcw3jxGWcHsWgwygT4
         FCeg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1792255142; x=1792859942;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :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=Ez6MSD+AceaDu7vNZmXph72FgmoMN2SxdaCBTXkP/s8=;
        b=rD4+q9pu/Yj74Y8Wh2/xm/I/+egEmOb1UQF8/E0z5uAwYSK5rQxu1qQDVp3eSfN1+D
         56/xbVUs2/ObmIcACjUjwJVBVrFT3CVA77c1RBRhDJOGh9jVHgAlA+ELua/2sK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a2hsthH
	AthzhG8iVvfWbSY9d4Tpdn/rLsY0OwJNPIukatHioAYSARXG9Nkdou4=
X-Received: by 2002:a17:90b:582d:b0:3ac:8af9:4a73 with SMTP id 98e67ed59e1d1-3acef10ee88mr2787745a91.28.1792255142075;
        Sat, 17 Oct 2026 09:39:02 -0700 (PDT)
X-Received: from coder-ast-ast-dev-ml-0.tail2dda0.ts.net ([153.61.198.241])
        by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3acd05fb680sm5145552a91.2.2026.10.17.09.39.01
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Sat, 17 Oct 2026 09:39:01 -0700 (PDT)
X-Cc: daniel@iogearbox.net,
	andrii@kernel.org,
	eddyz87@gmail.com,
	memxor@gmail.com,
	netdev@vger.kernel.org,
	josef@toxicpanda.com,
	mason@kernel.org
X-Mailer: git-send-email 2.55.0
X-In-Reply-To: <20261017163745.3341787-1-alexei.starovoitov@gmail.com>
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>