* [PATCH net 0/2] ipv6: drop encapsulated packets when no source address is available
@ 2026-11-15 0:00 Justin Iurman
2026-11-15 0:00 ` [PATCH net 1/2] ioam6: drop the packet if no outer " Justin Iurman
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Justin Iurman @ 2026-11-15 0:00 UTC (permalink / raw)
To: netdev; +Cc: davem, edumazet, kuba, pabeni, horms, andrea.mayer, justin.iurman
Both ioam6 and seg6 (encap modes) lwtunnels select the source address of
the outer IPv6 header with ipv6_dev_get_saddr() when no tunnel source is
configured, but ignore its return value. When no usable address is
available (e.g. none configured yet in the L3 domain, or only tentative
ones), the outer source address is left untouched:
- ioam6: it keeps the source address copied from the inner header,
which may belong to another node for in-transit traffic;
- seg6: the outer header has just been pushed, so it holds whatever
stale bytes were in the skb headroom.
Both patches drop the packet in that case, like other encapsulation
failures.
Justin Iurman (2):
ioam6: drop the packet if no outer source address is available
seg6: drop the packet if no outer source address is available
net/ipv6/ioam6_iptunnel.c | 11 +++++++----
net/ipv6/seg6_iptunnel.c | 26 ++++++++++++++++++--------
2 files changed, 25 insertions(+), 12 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net 1/2] ioam6: drop the packet if no outer source address is available
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 ` Justin Iurman
2026-11-16 5:47 ` Hangbin Liu
2026-11-15 0:00 ` [PATCH net 2/2] seg6: " Justin Iurman
2026-11-15 20:08 ` [PATCH net 0/2] ipv6: drop encapsulated packets when no " netdev-bot+sinfo
2 siblings, 1 reply; 7+ messages in thread
From: Justin Iurman @ 2026-11-15 0:00 UTC (permalink / raw)
To: netdev; +Cc: davem, edumazet, kuba, pabeni, horms, andrea.mayer, justin.iurman
When no tunnel source is configured, ioam6_do_encap() ignores the
return value of ipv6_dev_get_saddr(). On failure, the outer header
keeps the source address copied from the inner header, so the packet
is sent with an address that may not belong to this node.
Drop the packet instead.
Fixes: 8cb3bf8bff3c ("ipv6: ioam: Add support for the ip6ip6 encapsulation")
Signed-off-by: Justin Iurman <justin.iurman@gmail.com>
---
net/ipv6/ioam6_iptunnel.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/net/ipv6/ioam6_iptunnel.c b/net/ipv6/ioam6_iptunnel.c
index cfb2c41634a0..4990ae1ee78c 100644
--- a/net/ipv6/ioam6_iptunnel.c
+++ b/net/ipv6/ioam6_iptunnel.c
@@ -324,11 +324,14 @@ static int ioam6_do_encap(struct net *net, struct sk_buff *skb,
hdr->payload_len = cpu_to_be16(skb->len - sizeof(*hdr));
hdr->daddr = *tundst;
- if (has_tunsrc)
+ if (has_tunsrc) {
memcpy(&hdr->saddr, tunsrc, sizeof(*tunsrc));
- else
- ipv6_dev_get_saddr(net, dst_dev(dst), &hdr->daddr,
- IPV6_PREFER_SRC_PUBLIC, &hdr->saddr);
+ } else {
+ err = ipv6_dev_get_saddr(net, dst_dev(dst), &hdr->daddr,
+ IPV6_PREFER_SRC_PUBLIC, &hdr->saddr);
+ if (unlikely(err))
+ return err;
+ }
skb_postpush_rcsum(skb, hdr, len);
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net 2/2] seg6: drop the packet if no outer source address is available
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 ` Justin Iurman
2026-11-16 3:41 ` netdev-bot+sashiko
2026-11-15 20:08 ` [PATCH net 0/2] ipv6: drop encapsulated packets when no " netdev-bot+sinfo
2 siblings, 1 reply; 7+ messages in thread
From: Justin Iurman @ 2026-11-15 0:00 UTC (permalink / raw)
To: netdev; +Cc: davem, edumazet, kuba, pabeni, horms, andrea.mayer, justin.iurman
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>
---
net/ipv6/seg6_iptunnel.c | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/net/ipv6/seg6_iptunnel.c b/net/ipv6/seg6_iptunnel.c
index 3bc47c5614ff..395614fdb83f 100644
--- a/net/ipv6/seg6_iptunnel.c
+++ b/net/ipv6/seg6_iptunnel.c
@@ -107,12 +107,13 @@ static int nla_put_srh(struct sk_buff *skb, int attrtype,
return 0;
}
-static void set_tun_src(struct net *net, struct net_device *dev,
- struct in6_addr *daddr, struct in6_addr *saddr,
- struct in6_addr *route_tunsrc)
+static int set_tun_src(struct net *net, struct net_device *dev,
+ struct in6_addr *daddr, struct in6_addr *saddr,
+ struct in6_addr *route_tunsrc)
{
struct seg6_pernet_data *sdata = seg6_pernet(net);
struct in6_addr *tun_src;
+ int err = 0;
/* Priority order to select tunnel source address:
* 1. per route source address (if configured)
@@ -128,12 +129,14 @@ static void set_tun_src(struct net *net, struct net_device *dev,
if (!ipv6_addr_any(tun_src)) {
memcpy(saddr, tun_src, sizeof(struct in6_addr));
} else {
- ipv6_dev_get_saddr(net, dev, daddr,
- IPV6_PREFER_SRC_PUBLIC, saddr);
+ err = ipv6_dev_get_saddr(net, dev, daddr,
+ IPV6_PREFER_SRC_PUBLIC, saddr);
}
rcu_read_unlock();
}
+
+ return err;
}
/* Compute flowlabel for outer IPv6 header */
@@ -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;
#ifdef CONFIG_IPV6_SEG6_HMAC
if (sr_has_hmac(isrh)) {
@@ -304,7 +309,10 @@ static int seg6_do_srh_encap_red(struct sk_buff *skb,
if (skip_srh) {
hdr->nexthdr = proto;
- 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;
goto out;
}
@@ -340,7 +348,9 @@ static int seg6_do_srh_encap_red(struct sk_buff *skb,
srcaddr:
isrh->nexthdr = proto;
- 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;
#ifdef CONFIG_IPV6_SEG6_HMAC
if (unlikely(!skip_srh && sr_has_hmac(isrh))) {
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net 0/2] ipv6: drop encapsulated packets when no source address is available
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-15 20:08 ` netdev-bot+sinfo
2026-11-15 23:44 ` Justin Iurman
2 siblings, 1 reply; 7+ messages in thread
From: netdev-bot+sinfo @ 2026-11-15 20:08 UTC (permalink / raw)
To: Justin Iurman; +Cc: netdev, davem, edumazet, kuba, pabeni, horms, andrea.mayer
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by LLM and not proven at runtime). If it was triggered
please include the symptoms, like the stack trace or kernel messages.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net 0/2] ipv6: drop encapsulated packets when no source address is available
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
0 siblings, 0 replies; 7+ messages in thread
From: Justin Iurman @ 2026-11-15 23:44 UTC (permalink / raw)
To: netdev-bot+sinfo
Cc: netdev, davem, edumazet, kuba, pabeni, horms, andrea.mayer
On 11/15/26 21:08, netdev-bot+sinfo@kernel.org wrote:
> Hi!
>
> This is an automated message. This series looks like a fix, but its
> commit messages seem to be missing some information:
>
> - How the issue was discovered, e.g. hit in production, hit during
> development, syzbot report, manual code inspection, LLM or static
> analysis tool scan.
>
> - Whether the issue was actually triggered, or is only theoretical
> (e.g. found by LLM and not proven at runtime). If it was triggered
> please include the symptoms, like the stack trace or kernel messages.
>
> Please do not repost the series just to address the above. Instead,
> reply to this email with the missing information, so that reviewers
> can take it into account.
Found by manual code inspection (had this one in my queue for a long
time). It can be easily reproduced with a node that has no usable IPv6
address (no address on its interfaces, loopback down) forwarding traffic
(e.g., pings to make it simple) into a seg6 or ioam6 encap route with no
tunnel source configured. The outer source address of the encapsulated
packets is never selected: ioam6 sends them with the inner source
address (i.e., incorrect), while seg6 leaves it uninitialized (i.e.,
packets dropped as invalid: Ip6InAddrErrors).
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net 2/2] seg6: drop the packet if no outer source address is available
2026-11-15 0:00 ` [PATCH net 2/2] seg6: " Justin Iurman
@ 2026-11-16 3:41 ` netdev-bot+sashiko
0 siblings, 0 replies; 7+ messages in thread
From: netdev-bot+sashiko @ 2026-11-16 3:41 UTC (permalink / raw)
To: justin.iurman; +Cc: netdev, davem, edumazet, kuba, pabeni, horms, andrea.mayer
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net 1/2] ioam6: drop the packet if no outer source address is available
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
0 siblings, 0 replies; 7+ messages in thread
From: Hangbin Liu @ 2026-11-16 5:47 UTC (permalink / raw)
To: Justin Iurman; +Cc: netdev, davem, edumazet, kuba, pabeni, horms, andrea.mayer
On Sun, Nov 15, 2026 at 01:00:46AM +0100, Justin Iurman wrote:
> When no tunnel source is configured, ioam6_do_encap() ignores the
> return value of ipv6_dev_get_saddr(). On failure, the outer header
> keeps the source address copied from the inner header, so the packet
> is sent with an address that may not belong to this node.
>
> Drop the packet instead.
>
> Fixes: 8cb3bf8bff3c ("ipv6: ioam: Add support for the ip6ip6 encapsulation")
> Signed-off-by: Justin Iurman <justin.iurman@gmail.com>
> ---
> net/ipv6/ioam6_iptunnel.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/net/ipv6/ioam6_iptunnel.c b/net/ipv6/ioam6_iptunnel.c
> index cfb2c41634a0..4990ae1ee78c 100644
> --- a/net/ipv6/ioam6_iptunnel.c
> +++ b/net/ipv6/ioam6_iptunnel.c
> @@ -324,11 +324,14 @@ static int ioam6_do_encap(struct net *net, struct sk_buff *skb,
> hdr->payload_len = cpu_to_be16(skb->len - sizeof(*hdr));
> hdr->daddr = *tundst;
>
> - if (has_tunsrc)
> + if (has_tunsrc) {
> memcpy(&hdr->saddr, tunsrc, sizeof(*tunsrc));
> - else
> - ipv6_dev_get_saddr(net, dst_dev(dst), &hdr->daddr,
> - IPV6_PREFER_SRC_PUBLIC, &hdr->saddr);
> + } else {
> + err = ipv6_dev_get_saddr(net, dst_dev(dst), &hdr->daddr,
> + IPV6_PREFER_SRC_PUBLIC, &hdr->saddr);
> + if (unlikely(err))
> + return err;
> + }
>
> skb_postpush_rcsum(skb, hdr, len);
>
> --
> 2.34.1
>
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-16 5:47 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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-15 20:08 ` [PATCH net 0/2] ipv6: drop encapsulated packets when no " netdev-bot+sinfo
2026-11-15 23:44 ` Justin Iurman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox