Article View: linux.kernel.netdev
Article #25015Re: [PATCH net-next v5 08/12] amt: receive the AMT gateway control plane over IPv6
From: netdev-bot+sashiko
Date: Tue, 01 Dec 2026 06:46
Date: Tue, 01 Dec 2026 06:46
280 lines
18937 bytes
18937 bytes
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
Technical Details
Message-ID:
<179610758198.3146.6656245343534391357@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!193.141.40.65.MISMATCH!npeer.as286.net!npeer-ng0.as286.net!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374758-linux-kernel-netdev=dewy.ruReferences:
<20261130064249.1874523-9-omar@blockcast.net>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!193.141.40.65.MISMATCH!npeer.as286.net!npeer-ng0.as286.net!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374758-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev 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 Organization: Usenet Network Message-ID: <179610758198.3146.6656245343534391357@kernel.org> References: <20261130064249.1874523-9-omar@blockcast.net> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1639719"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:8FNMHhMYPLINzFvLzV4ZTilih/c= sha256:oY2/bVA+MYoMWSSHDzA0mniBxta0ibnSiRfvY7B5HbY= sha1:xdhxTRJgdCkKOQRlmgNoK4pOkDA= sha256:N/O6gJHhnRORdl/YUBTIwKTTtyAZwOGGA5F9D8yeGVg= 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 3DA35117278; Tue, 1 Dec 2026 09:47:20 +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 cd1xXIfI_TAm; Tue, 1 Dec 2026 09:47:16 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374758-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 3A231117266; Tue, 1 Dec 2026 09:47:08 +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 B48FC2CE20; Tue, 1 Dec 2026 06:46:32 +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=1796107584; b=QZs/PW46UUC3Y+ZCmL8fCTFhKceZiMNnfeUaoVJjsgcPk3TtRCCr1gdIfC+NbkdnbnAh YC4C4b2Vl8bJdxQ6kT7UnkXdhnrDcnw8HvVmTmdTyJizbwy/PI/kvT2iC/3qfmTA3soN9 FaN7EgZDE1g6LUMSd0YBt5XA6zUc/tMl25VbvlEEU+vdpDB574VuPiNw6pMYi4fJxbqmk 3EgTO+TIYKK7BsItqy/NJIkrPluOP0WeedrlJ6ucRKxe+1larDuMsPpTztj5ymLTecjh6 MN7LajX6gRUO9pdJ97Bpm20TiQRzlcmrI4o4l2zZKdaYx82VPXPWruEogiQxTCrKaTQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796107584; 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=PsfLW2R8BwUpbmb+5MUJ2f9ipVeqQhashcO3GZbuFGc=; b=yrqOi1z3+4ksImO5kcvcQ+zY3pOlEf2kLrEeAv8PxpMDxaeIl88LJAiMC8NqySjEFqRW 24YfSWWLAbEnnpd1dYyMTEKbHwomz/76CUxbmZvLWqQWW/FFQ3AoM283eVnpf7K6wGhgF K/qUrXRhTGnuwCZVmWiDemf3d1Rmmd+T/NgPzR8ibAtB2Yblj7LiuHvd1zcVulMrVyTpR mdPzQF1YsCZ+Vl5y4z0y8FhQ6H5wxFLShV2h9DKNHtVO7D/BDAWS2e13bPre9YrXYMB0O jnLWqrb0e3rBs8v15+Ln+I9XGUyKgkMGUQEjejtEZjhxyiN8gjYf1pYfiPZ0tFQ7Gxw== 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=THcNzifv; 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 8C4C460A260C; Tue, 1 Dec 2026 06:46:24 +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=THcNzifv 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=1796107583; b=iL39l4GeFH1yt6U+FpulBuQ1TInHJ5Cw6iQanMWdtGRh/tlJk5pMpAjEpomH7lsZOWOk KUiDxsx87zKyxdyP8o6jrJ+9fYfIA6U3Sf/PFK0MRXNXgiTXUGTllrDEOjyawXZ8hK746 BOZdql879Se/mOLjbU7lFXK3Rb1Gm7djXTODEGXtwO7OQ7cXXb1+9bC7zMYKJJBmb2QWj w6mLegHKV2SJTL4XqS2nci4kkNFXrsDqk7L82QfKUc4GvrMKfLK/5tXxde81nShwDMuNr ihCzITmbVfrR2k46ysIurJ5F/wyCB/4Q4L8xDehhzVX6YtcP52vId5eEE/+Cb0c1nTA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796107583; 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=PsfLW2R8BwUpbmb+5MUJ2f9ipVeqQhashcO3GZbuFGc=; b=FBwh4BPpjcaoCCiRvEBlYnrl8x/n70tWDTMwqfSnYCe0dd7k1raLpg9l7SPOTn5Dzsv6 jgGJmM89WN7Ey6nI+27DiNB9EnGeleEKV8tnZsnuZBgrs0zgGek+xQfMJ+e1ADkFB5KxW OjWlipfqfHZshIpQvMzJJbvfE6R0J8S/ihf70xhyMfMi+DM+R3O62oCPjtHHPEW8Wj4J8 a5h7KP6RLs2NBSb87ptg85d7A4gHBu452/b3FBpK1LE1ZfYBc5CnTxKCB24nfPicSrdhJ Ia5sn7IzUAM8uELKn2lIwNFQZXDC//EVeGkxIjbb1RCYCi8D3a/bJ9Gldq5vX3wG7xw== 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=THcNzifv; 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 AD43F606A6A1; Tue, 1 Dec 2026 06:46:23 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 730DB1F00919; Tue, 1 Dec 2026 06:46:22 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796107583; bh=PsfLW2R8BwUpbmb+5MUJ2f9ipVeqQhashcO3GZbuFGc=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=THcNzifvys3f40FeBcHv9xnFXY1TZVG+7ni6tb6Ng16GagTQmclyxXSZay3NQFw72 Dvb2nWd0GmZf2t6uD/YS8yVsKQgc7bl2TwyONtMyukDSRvshKA96xCKqnTaux705lF hjqO3VLkY5BMkvBZoy68pE+NvEqorjCiSUJmZ5W9IuprmBGUYZneGVEi3tHKejeD3i AK6vncPmt/7lbuhnF/13v9MIGvksmg8OWthIleDXuwUlR5lK5atSSLZp75+e1EeR15 SUZIRAY1q/bhy4yRUD4QorKyLTcBjpnVcKpB6QWYkf0uwx11oYgWvYzPVJVInvxE0H scmLarpgvK6Cg== X-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 X-In-Reply-To: <20261130064249.1874523-9-omar@blockcast.net> X-sashiko-severity: High 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