From: Justin Iurman <justin.iurman@gmail.com>
To: Andrea Mayer <andrea.mayer@uniroma2.it>
Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
Stefano Salsano <stefano.salsano@uniroma2.it>,
Hangbin Liu <hangbin.liu@linux.dev>,
Andrea Mayer <andrea@common-net.org>
Subject: Re: [PATCH net 2/2] seg6: drop the packet if no outer source address is available
Date: Sat, 21 Nov 2026 14:54:57 +0100 [thread overview]
Message-ID: <7e916e9e-8305-4842-9132-d380d9b6e4ce@gmail.com> (raw)
In-Reply-To: <20261118031208.38cbdb5e2c4183da17904095@uniroma2.it>
On 11/18/26 03:12, Andrea Mayer wrote:
> On Sun, Nov 15, 2026 at 01:00:47AM +0100, Justin Iurman wrote:
>> When no tunnel source is configured, set_tun_src() ignores the return
>> value of ipv6_dev_get_saddr(). On failure, the source address of the
>> freshly pushed outer header is never written, so the packet is sent
>> with whatever stale bytes were in the skb headroom.
>>
>> Return the error from set_tun_src() and drop the packet; all callers
>> of the encap functions already handle their errors.
>>
>> Fixes: 6c8702c60b88 ("ipv6: sr: add support for SRH encapsulation and injection with lwtunnels")
>> Signed-off-by: Justin Iurman <justin.iurman@gmail.com>
>> [snip]
>
> Hi Justin,
>
> the overall fix looks good. The Sashiko review makes a good point about
> the BPF callers. They do not drop the packet, they return the error to
> the program. If the program ignores it, the packet can still go out with
> stale headroom bytes as the source address, and now a wrong payload_len
> too.
>
> It makes sense to select the source before skb_cow_head(), as the review
> suggests. On failure the encap returns before touching the packet. The
> source goes into a local address, then into the header where
> set_tun_src() writes it today. That is before the HMAC push, since the
> HMAC covers the source. For example, in __seg6_do_srh_encap():
>
> struct in6_addr saddr;
> ...
> err = set_tun_src(net, dev, &osrh->segments[osrh->first_segment],
> &saddr, route_tunsrc);
> if (unlikely(err))
> return err;
>
> err = skb_cow_head(skb, ...);
> ...
> hdr->saddr = saddr;
>
> seg6_do_srh_encap_red() has the same two call sites, the skip_srh path
> and the slow path. Both would use the source resolved once at the top.
>
> Also, a local sender now gets EADDRNOTAVAIL from sendto(), where before
> the send succeeded. Might be worth a line in the commit message, with
> the reproduction you already gave the bot.
>
> WDYT?
>
> Thanks,
> Andrea
Agreed, I'll take care of this ASAP.
pw-bot: cr
next prev parent reply other threads:[~2026-11-21 13:55 UTC|newest]
Thread overview: 9+ 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-16 5:47 ` Hangbin Liu
2026-11-15 0:00 ` [PATCH net 2/2] seg6: " Justin Iurman
2026-11-16 3:41 ` netdev-bot+sashiko
2026-11-18 2:12 ` Andrea Mayer
2026-11-21 13:54 ` Justin Iurman [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=7e916e9e-8305-4842-9132-d380d9b6e4ce@gmail.com \
--to=justin.iurman@gmail.com \
--cc=andrea.mayer@uniroma2.it \
--cc=andrea@common-net.org \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=hangbin.liu@linux.dev \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stefano.salsano@uniroma2.it \
/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