From: netdev-bot+sashiko@kernel.org
To: justin.iurman@gmail.com
Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
andrea.mayer@uniroma2.it
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 [thread overview]
Message-ID: <179480047386.3136.1354948992890219716@kernel.org> (raw)
In-Reply-To: <20261115000047.14669-3-justin.iurman@gmail.com>
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
next prev parent reply other threads:[~2026-11-16 3:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 0:00 [PATCH net 0/2] ipv6: drop encapsulated packets when no source address is available Justin Iurman
2026-11-15 0:00 ` [PATCH net 1/2] ioam6: drop the packet if no outer " Justin Iurman
2026-11-15 0:00 ` [PATCH net 2/2] seg6: " Justin Iurman
2026-11-16 3:41 ` netdev-bot+sashiko [this message]
2026-11-15 20:08 ` [PATCH net 0/2] ipv6: drop encapsulated packets when no " netdev-bot+sinfo
2026-11-15 23:44 ` Justin Iurman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179480047386.3136.1354948992890219716@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrea.mayer@uniroma2.it \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=justin.iurman@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox