๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #16927

Re: [PATCH net 2/2] seg6: drop the packet if no outer source address is available

#16927
From: netdev-bot+sashiko
Date: Mon, 16 Nov 2026 03:41
116 lines
12154 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 ยท High: 0 ยท Medium: 1 ยท Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The patch fixes the seg6 lwtunnel and seg6local callers, but
  the BPF callers of the same encap path can still send the packet.

--

seg6: drop the packet if no outer source address is available

With this change, set_tun_src() returns the error from ipv6_dev_get_saddr()
instead of ignoring it. __seg6_do_srh_encap() and seg6_do_srh_encap_red()
now return early on that error, so that a packet is not sent with stale
headroom bytes as its outer source address.

> diff --git a/net/ipv6/seg6_iptunnel.c b/net/ipv6/seg6_iptunnel.c
> index 3bc47c5614ff4..395614fdb83f3 100644
> --- a/net/ipv6/seg6_iptunnel.c
> +++ b/net/ipv6/seg6_iptunnel.c

[ ... ]

> @@ -213,7 +216,9 @@ static int __seg6_do_srh_encap(struct sk_buff *skb, struct ipv6_sr_hdr *osrh,
>  	isrh->nexthdr = proto;
>  
>  	hdr->daddr = isrh->segments[isrh->first_segment];
> -	set_tun_src(net, dev, &hdr->daddr, &hdr->saddr, route_tunsrc);
> +	err = set_tun_src(net, dev, &hdr->daddr, &hdr->saddr, route_tunsrc);
> +	if (unlikely(err))
> +		return err;

[Severity: Medium]
Does every caller of seg6_do_srh_encap() drop the skb when this returns an
error?

At this point __seg6_do_srh_encap() has already called skb_push(skb, tot_len).
It has also rebuilt the network and mac headers and copied the SRH. On
failure, hdr->saddr is still unwritten, because ipv6_dev_get_saddr() only
writes *saddr on success. The payload_len write and skb_postpush_rcsum() are
skipped, and the push is not undone.

The lwtunnel paths (seg6_input_core() and seg6_output_core()) and
input_action_end_b6_encap() free the skb on error. bpf_push_seg6_encap() in
net/core/filter.c does not:

net/core/filter.c:bpf_push_seg6_encap() {
    ...
	case BPF_LWT_ENCAP_SEG6:
		skb_reset_inner_headers(skb);
		skb->encapsulation = 1;
		err = seg6_do_srh_encap(skb, srh, IPPROTO_IPV6);
		break;
    ...
	bpf_compute_data_pointers(skb);
	if (err)
		return err;
    ...
}

This function is reached from bpf_lwt_push_encap(BPF_LWT_ENCAP_SEG6) in
LWT_IN programs, and from bpf_lwt_seg6_action(SEG6_LOCAL_ACTION_END_B6_ENCAP).
The second caller expects the header to stay in place after an error:

	err = bpf_push_seg6_encap(skb, BPF_LWT_ENCAP_SEG6,
				  param, param_len);
	/* The header can be in place although err says otherwise */
	bpf_update_srh_state(skb);

	return err;

On this path, can the BPF program read the 16 uninitialized saddr bytes and
the stale payload_len through direct packet access? bpf_skb_generic_push()
zeroes pushed space to avoid exactly this.

If the program ignores the helper's return value and returns BPF_OK, it looks
like input_action_end_bpf() still forwards the skb. seg6_bpf_has_valid_srh()
passes because the SRH was copied before the failure, and the skb then goes
through seg6_lookup_nexthop() and dst_input(). run_lwt_bpf() treats BPF_OK
the same way.

In that case, would the packet still go out with stale headroom as its outer
source address, a wrong payload_len, and an inconsistent CHECKSUM_COMPLETE
csum? This is the case the commit message describes as fixed.

This can be triggered when no per-route or per-netns tunsrc is set and
ipv6_dev_get_saddr() returns -EADDRNOTAVAIL. Examples are a link-local or
multicast first SID, or use_oif_addrs_only set, with no usable address on
the egress device.

The commit message says:

    Return the error from set_tun_src() and drop the packet; all callers
    of the encap functions already handle their errors.

That does not seem to hold for the BPF callers. Would it be better to resolve
the tunnel source into a local struct in6_addr before skb_cow_head() and
skb_push()? Then a failed encap would leave the skb untouched for every
caller.

>  
>  #ifdef CONFIG_IPV6_SEG6_HMAC
>  	if (sr_has_hmac(isrh)) {

[ ... ]

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261115000047.14669-1-justin.iurman%40gmail.com
Technical Details
Message-ID: <179480047386.3136.1354948992890219716@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364034-linux-kernel-netdev=dewy.ru
References: <20261115000047.14669-3-justin.iurman@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364034-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 2/2] seg6: drop the packet if no outer source address
 is available
Date: Mon, 16 Nov 2026 03:41:13 +0000
Organization: Usenet Network
Message-ID: <179480047386.3136.1354948992890219716@kernel.org>
References: <20261115000047.14669-3-justin.iurman@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1970779"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:St0uFubaerjZTxCFSdtxm/Endgo= sha256:YlMKrc3EP4Mob5bUIjioCW9nLEMcHf55wb1eevG455M=
	sha1:WQVRWhWGAbgF97Nq9v12DzfX+4M= sha256:8Mtwg0H2UV6kG9aOxaBmqR3U+sxD7fNOdM44/PuMBR8=
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 78922114B13; Mon, 16 Nov 2026 06:41:29 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, 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, URIBL_BLOCKED=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 lPhFqd23DSBg;
	Mon, 16 Nov 2026 06:41:25 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-364034-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 885B3114B0B; Mon, 16 Nov 2026 06:41:17 +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 2439F2DD8B; Mon, 16 Nov 2026 03:41:16 +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=1794800476;
	b=XYOGFJOFANnA7FfUyU14Hs6ivAGEVlQ39zZYbuJIBihTnWq2Z6oOssgaESh2ZGEzXeeA
	 /i8hDR3Dr6zjdA5gWIT/PROg3/joFEU9LubURIqKMK8crsQRSuIX/PrJGhFkagI7ngpg0
	 +hbrUsEOSZC3qlDDdNcGVEsHlHo8Tsdb90bMcVLqV34OyAcDEFvhkTtvtq51ASoVC3GGH
	 cJ3tH0qjrWDKohc5dMmrlYvEeZsGEgOJiZbUoBl+G+RrMo9IEWLaMcSuBHhEJCCPoq2zw
	 eo+S+WvzohA63t2/geecG0AmulEA8ORA2hSjbC2pM0l/JrD0EkyscwTtkGwjFqXn3sA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794800476;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=pBYpLLyYTuBK9CRoRtN49pj0op5fF/cCdNRMi340gxA=;
	b=cUVvx658wmoUM3K+aYHEiqwDKOMgHsD6WrnGoD8ur1iORrXEBtw89oTp7CPboGJ9h3Sy
	 H4bxLqu2Xo/7VuN87sHXS9txlYYYHT9ztxeWGXQ19uYARRdhcc2JydJRNqKUyuDiokO1i
	 bT9Fm9M5Hz4B8ii30zK1flkETe7HzZxGzqw/b8j333ItQz8cRJvdWV8uPjN+LkKCJlEZ3
	 r46uXvSu0RSikpuQ7ftPZx7X7H6v4VDX6alk3BqWVXoc3PwZUw6uNyN6KZz4bQUqDdDeM
	 baT1TGyKox57IkKWxUqFtkMryjpo5M8FerMHuOSLfJlurhwoGzBEA4y5wRa9u0z2fIw==
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=WsAignx8;
	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 F010C606A32F;
	Mon, 16 Nov 2026 03:41:15 +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=WsAignx8
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=1794800475;
	b=dSHnVfaG7HLwpLsXqA09KM+KvcK8Fepl4YB+Xfc/7gi0ksRJKUUQ0NDcmSeZm/12h4l9
	 tD1O0VAKL1SX7aT4han3f1cm6VlyGTJDXeZnzKrc0uqBRnbO6Uif7iaJd6qvNfhpA3ZU/
	 z9U/I69vkS0U78bIUq7GNvpnpTuZhZZtsxbwExCCqLFLnaqrRt9mR9FUKw5jPpo+0voCl
	 lFkCCIDTMcjh+KIwqMBRa/hHBaW+dksBJWYcJvAOaVJJoudNjtPNfRkFlS29xXCdRttcd
	 RzRCPA0s+uEGzgQGaOYb+R3tQszGRopZWFvOIxFlCSt0Otnb2ror1gvqIQ/HjVqz/mA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794800475;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=pBYpLLyYTuBK9CRoRtN49pj0op5fF/cCdNRMi340gxA=;
	b=zY0elxnJD9+WKH4P4N6QITsJ5EnTKnCxdzyrZxoTK1hyMoo0C2+Hw0JZNCgkNEqdSZ9K
	 AIdTb7s2x57KbMvuI/YC7V4MUFMhfo1Y2Wd6iKOdmP7+N1a9JlRkLevnJ3NFMWUDA1Jd9
	 9Oy+g+YsCIoTmMkkG0YzcXD/9ZYs3z212Tj2SSKIFiR2LqYaSi5fttRnHB1AAS691kNw/
	 hJBxiAte9XSLMBXqt5Uw/t3yrVp9yag4YAHVp9eHMISARnByPPKCmnnAQ8JdHvu8eTw6r
	 Bes3Hnea84KAcGpELgKzMKadZyi8ot2jLW4sIdL6fb+Iivfi5VjSe6RRDNe/D5MWkdw==
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=WsAignx8;
	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 14D57606A31C
	for <netdev@vger.kernel.org>; Mon, 16 Nov 2026 03:41:15 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C9771F000C4;
	Mon, 16 Nov 2026 03:41:14 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794800474;
	bh=pBYpLLyYTuBK9CRoRtN49pj0op5fF/cCdNRMi340gxA=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=WsAignx8r2McRfA7Gd7d9sWBNv3e9epcnF6xvP1VxCojnUjrJmLk/H3yXmzZR4VJq
	 p9i4FBHI608hH2wTK6HxuxrBT0iadscqTRzPnMIqglUITRuifDqEwfr+WlagDYpqbM
	 F7ymCft7h0nr3W08xUGj14MFH9ct0Unl1FSnS0kAft8+ZZSDrwG+o0cSW9aRXlzNEy
	 wxaFtK2xtIBt0hbvbeM6YAg4ov+LD2Ldhe8JqHsMmx0JjYZsa5ciBCF9NlFFls39hC
	 C/ZBqfejZ7j7XijDA9X65kYfBS45yfw700j47s/O9SWIQjRquuqxHvfbZi0UIvpMss
	 Pskfrfcf4TL3Q==
X-Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@kernel.org,
 kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
 andrea.mayer@uniroma2.it
X-In-Reply-To: <20261115000047.14669-3-justin.iurman@gmail.com>
X-sashiko-severity: Medium
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