From: netdev-bot+sashiko@kernel.org
To: omar@blockcast.net
Cc: ap420073@gmail.com, andrew+netdev@lunn.ch, davem@davemloft.net,
edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
shuah@kernel.org, horms@kernel.org, netdev@vger.kernel.org,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
willemb@google.com
Subject: Re: [PATCH net-next v5 08/12] amt: receive the AMT gateway control plane over IPv6
Date: Tue, 01 Dec 2026 06:46:21 +0000 [thread overview]
Message-ID: <179610758198.3146.6656245343534391357@kernel.org> (raw)
In-Reply-To: <20261130064249.1874523-9-omar@blockcast.net>
Thank you for your contribution! Sashiko AI review found 6 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 2 · Low: 3
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).
- [High] The relay's own-source filter in amt_rcv() only walks the
unicast list.
- [Medium] The relay's new own-source drop in amt_rcv() calls
ipv6_chk_addr(amt->net, &saddr.ip6, NULL, 0).
- [Medium] The relay's own-source check in amt_rcv() calls
ipv6_chk_addr(amt->net, &saddr.ip6, NULL, 0).
- [Low] The commit message says this patch makes the IPv6 gateway control
plane work ("An IPv6 gateway now sends its Discovery, Request and…
- [Low] Part of the commit message's case for the seqlock is that
remote_ipv6 "is read ... from amt_fill_info(), which no longer relies…
- [Low] The block comment above amt_set_remote_ipv6()
(drivers/net/amt.c:857-861) says the learned relay address "is written…
--
amt: receive the AMT gateway control plane over IPv6
This patch makes amt_rcv() and amt_advertisement_handler() handle an IPv6
outer header. It publishes the learned IPv6 relay address under a new
seqlock, and adds a relay-side drop for packets whose IPv6 source is one of
the host's own addresses. It also lets an IPv6 gateway socket accept a zero
UDP checksum, and only for Multicast Data.
> An IPv6 gateway now sends its Discovery, Request and Updates over IPv6,
> but it cannot take the replies.
[ ... ]
> need no change. With this an IPv6 gateway discovers an IPv6 relay,
> completes the Request, Query and Update exchange and receives multicast,
> as an IPv4 gateway does.
[Severity: Low]
Is this accurate at this point in the series? At this commit nothing
assigns amt->local_ipv6, and amt_validate() still requires the IPv4 local
attribute:
drivers/net/amt.c:amt_validate() {
...
if (!data[IFLA_AMT_LOCAL_IP]) {
NL_SET_ERR_MSG_ATTR(extack, data[IFLA_AMT_DISCOVERY_IP],
"Local attribute is required");
...
}
IFLA_AMT_LOCAL_IP6 and IFLA_AMT_DISCOVERY_IP6 don't exist yet, so amt_v6()
is false for every device. None of the new IPv6 branches can run until the
later "amt: add netlink attributes for an IPv6 outer transport" commit:
- the 24-byte Advertisement parse
- the :: source drop
- the relay's own-source drop
- the zero-checksum handling in amt_rcv()
- the use_udp6_rx_checksums change
Earlier patches in the series say that amt_v6() is still false and nothing
changes functionally. The next patch says no such device can be created
until it lands. Could this message say the same, rather than describing
the behaviour as already active?
> The IPv6 relay address needs more care than the IPv4 one. The
> Advertisement handler, its only writer, runs from the event workqueue,
> while it is read in softirq, on receive and on transmit, and from
> amt_fill_info(), which no longer relies on RTNL.
[ ... ]
> and amt_dev_stop(), so a gateway that is taken down and up again neither
> accepts traffic from its previous relay's IPv6 address nor keeps
> reporting it.
[Severity: Low]
Does amt_fill_info() read remote_ipv6 at this commit? It seems to report
only the IPv4 address:
drivers/net/amt.c:amt_fill_info() {
...
remote_ip = READ_ONCE(amt->remote_ip);
if (remote_ip)
if (nla_put_in_addr(skb, IFLA_AMT_REMOTE_IP, remote_ip))
goto nla_put_failure;
...
}
IFLA_AMT_REMOTE_IP6 doesn't exist yet. The amt_fill_info() reader, and the
"reporting" mentioned later, only arrive with the later netlink attributes
commit. That commit does read the field through amt_get_remote_ipv6(), so
the code ends up correct. The only problem is that this commit's message
describes a reader that isn't there yet.
> diff --git a/drivers/net/amt.c b/drivers/net/amt.c
> index 13cf36332b05f..eabb3c4074915 100644
> --- a/drivers/net/amt.c
> +++ b/drivers/net/amt.c
[ ... ]
> @@ -848,6 +854,61 @@ static int amt_send_ctrl_v6(struct amt_dev *amt, const struct in6_addr *saddr,
> return err;
> }
>
> +/* The learned relay address is written by the event worker and read by the
> + * softirq RX and TX paths. A struct in6_addr cannot be stored or loaded in
> + * one access, so it is published under a seqlock, and every consumer takes
> + * one snapshot per packet.
> + */
> +static void amt_set_remote_ipv6(struct amt_dev *amt,
> + const struct in6_addr *addr)
> +{
> + write_seqlock_bh(&amt->remote_ipv6_lock);
> + amt->remote_ipv6 = *addr;
> + write_sequnlock_bh(&amt->remote_ipv6_lock);
> +}
[ ... ]
> +/* Forget the relay a gateway learned, in both outer families. */
> +static void amt_clear_remote(struct amt_dev *amt)
> +{
> + WRITE_ONCE(amt->remote_ip, 0);
> + amt_set_remote_ipv6(amt, &in6addr_any);
> +}
[Severity: Low]
Is the single-writer description in the comment above amt_set_remote_ipv6()
accurate? The commit message also calls the Advertisement handler "its only
writer".
amt_clear_remote() also writes remote_ipv6 through amt_set_remote_ipv6().
It is called from amt_event_send_request() in the event worker, and also
from amt_dev_open() and amt_dev_stop() in process context. In
amt_dev_open() the call comes after amt_socket_create() has enabled
receive, so it can run at the same time as the event worker.
write_seqlock_bh() serialises all of these writers, so nothing is corrupted
today. Could the comment and the commit message mention the open and stop
writers too? Otherwise a later change might rely on the single-writer
description and replace the seqlock with a bare seqcount_t.
[ ... ]
> @@ -3461,10 +3547,31 @@ static int amt_rcv(struct sock *sk, struct sk_buff *skb)
[ ... ]
> + /* IPv4 input refuses a source that is one of this host's own
> + * addresses as a martian (accept_local is 0) when it arrives from
> + * the wire, but IPv6 input delivers it. A relay answers a Discovery
> + * and a Request to their source, so a forged one would make it send
> + * to itself over lo, where a rule such as "-i lo -j ACCEPT" lets it
> + * in. A packet that arrives over lo comes from this host, as for
> + * IPv4, so a gateway on the relay's host still reaches it.
> + */
> + if (amt_v6(amt) && amt->mode == AMT_MODE_RELAY &&
> + skb->skb_iif != amt->net->loopback_dev->ifindex &&
> + ipv6_chk_addr(amt->net, &saddr.ip6, NULL, 0)) {
> + err = true;
> + goto drop;
> + }
[Severity: High]
Does this check cover anycast addresses that the relay delivers locally?
ipv6_chk_addr() only walks the unicast list, net->ipv6.inet6_addr_lst.
With forwarding enabled on stream_dev, addrconf_join_anycast() joins the
Subnet-Router anycast (prefix::) of each prefix. An admin may also add an
anycast Relay Discovery Address, which RFC 7450 anticipates. These get an
RTF_ANYCAST route, and ip6_rt_get_dev_rcu() sends traffic for them through
loopback:
net/ipv6/route.c:ip6_rt_get_dev_rcu() {
...
if (res->fib6_flags & (RTF_LOCAL | RTF_ANYCAST)) {
...
else if (!netif_is_l3_master(dev))
dev = dev_net(dev)->loopback_dev;
...
}
ip6_rcv_core() doesn't refuse an anycast source. A forged Discovery or
Request from the wire with source prefix:: would pass this check:
amt_rcv()
ipv6_chk_addr() /* returns 0 for the anycast address */
amt_discovery_handler() / amt_request_handler()
amt_route6() /* oif = stream_dev, matches the RTF_ANYCAST route */
reply delivered over lo to local UDP listeners on ::
Isn't that the same self-reflection past "-i lo -j ACCEPT" that the commit
message says this check prevents? IPv4 refuses both local and broadcast
sources as martians.
Would adding an anycast lookup close it? For example, ipv6_chk_acast_addr()
on &saddr.ip6, with NULL or amt->stream_dev as the device.
[Severity: Medium]
Can this drop a legitimate gateway that uses a link-local source?
ipv6_chk_addr() passes skip_dev_check = !dev. With a NULL device, the match
in __ipv6_chk_addr_and_flags() accepts an equal address of any scope on any
device in the namespace:
net/ipv6/addrconf.c:__ipv6_chk_addr_and_flags() {
...
if (ipv6_addr_equal(&ifp->addr, addr) &&
!(ifp_flags&banned_flags) &&
(!dev || ndev == dev ||
!(ifp->scope&(IFA_LINK|IFA_HOST) || strict))) {
...
}
Link-local addresses are only unique per link, and a static fe80::1 on
several interfaces is common on routers. Suppose a gateway on the stream_dev
link sources from fe80::X, and the relay has fe80::X on another interface.
Then every Discovery, Request and Membership Update from that gateway is
dropped here and counted in rx_dropped.
In that case the drop doesn't prevent any reflection. amt_route6() routes
the reply with oif = stream_dev on a device-bound socket, so the reply goes
out the stream_dev link. The comment in amt_create_sock() also explicitly
supports link-local peers on stream_dev.
Would passing amt->stream_dev as the device, without skip_dev_check, fix
this? It would still match global-scope addresses, but would only match
stream_dev's own link-local addresses.
[Severity: Medium]
What happens here when stream_dev is enslaved to a VRF? In
__ipv6_chk_addr_and_flags(), l3mdev is taken from the dev argument before
skip_dev_check clears it:
net/ipv6/addrconf.c:__ipv6_chk_addr_and_flags() {
...
l3mdev = l3mdev_master_dev_rcu(dev);
if (skip_dev_check)
dev = NULL;
hlist_for_each_entry_rcu(ifp, &net->ipv6.inet6_addr_lst[hash], addr_lst) {
ndev = ifp->idev->dev;
if (l3mdev_master_dev_rcu(ndev) != l3mdev)
continue;
...
}
With a NULL dev, l3mdev is NULL, so every address on a VRF slave is skipped.
That includes the relay's own addresses on stream_dev. A forged Discovery or
Request from the wire with one of those as its source would pass this
check, and the reply would follow this path:
amt_discovery_handler() / amt_request_handler()
amt_route6() /* oif = stream_dev, finds the RTF_LOCAL route */
ip6_rt_get_dev_rcu() /* dst dev becomes the VRF master */
reply delivered locally to UDP listeners in that VRF
The commit message notes "An address on a VRF slave or a tentative one is
not found". Isn't this still the self-reflection the check is meant to
close? IPv4's fib_validate_source() looks the source up in the l3mdev
table.
Would something like this keep the L3 domain and cover this case?
ipv6_chk_addr_and_flags(amt->net, &saddr.ip6, amt->stream_dev,
false, 0, IFA_F_TENTATIVE)
The findings above were generated by an automated review.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130064249.1874523-1-omar%40blockcast.net
next prev parent reply other threads:[~2026-12-01 6:46 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 6:42 [PATCH net-next v5 00/12] amt: add an IPv6 outer transport Omar Ramadan
2026-11-30 6:42 ` [PATCH net-next v5 01/12] amt: create an AF_INET6 encapsulation socket for an IPv6 outer address Omar Ramadan
2026-11-30 6:42 ` [PATCH net-next v5 02/12] amt: send the Relay Advertisement over IPv6 Omar Ramadan
2026-12-01 6:46 ` netdev-bot+sashiko
2026-11-30 6:42 ` [PATCH net-next v5 03/12] amt: key relay tunnels on a union amt_addr endpoint Omar Ramadan
2026-12-01 6:46 ` netdev-bot+sashiko
2026-11-30 6:42 ` [PATCH net-next v5 04/12] amt: send the Membership Query over IPv6 Omar Ramadan
2026-11-30 6:42 ` [PATCH net-next v5 05/12] amt: forward multicast data " Omar Ramadan
2026-12-01 6:46 ` netdev-bot+sashiko
2026-11-30 6:42 ` [PATCH net-next v5 06/12] amt: size the encapsulation headroom by the outer IP version Omar Ramadan
2026-11-30 6:42 ` [PATCH net-next v5 07/12] amt: send the AMT gateway control plane over IPv6 Omar Ramadan
2026-11-30 6:42 ` [PATCH net-next v5 08/12] amt: receive " Omar Ramadan
2026-12-01 6:46 ` netdev-bot+sashiko [this message]
2026-11-30 6:42 ` [PATCH net-next v5 09/12] amt: add netlink attributes for an IPv6 outer transport Omar Ramadan
2026-11-30 6:42 ` [PATCH net-next v5 10/12] MAINTAINERS: amt: cover the amt headers and selftests Omar Ramadan
2026-11-30 6:42 ` [PATCH net-next v5 11/12] selftests: net: add amt_v6.sh for an IPv6 outer transport Omar Ramadan
2026-12-01 6:46 ` netdev-bot+sashiko
2026-11-30 6:42 ` [PATCH net-next v5 12/12] selftests: net: add amt_gw_v6.sh for the IPv6 netlink attributes Omar Ramadan
2026-12-01 6:46 ` netdev-bot+sashiko
2026-11-30 17:27 ` [PATCH net-next v5 00/12] amt: add an IPv6 outer transport Matthieu Baerts
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=179610758198.3146.6656245343534391357@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=ap420073@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=omar@blockcast.net \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
--cc=willemb@google.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