Re: [PATCH net-next v2 03/12] amt: key relay tunnels on a union amt_addr endpoint

From: netdev-bot+sashiko

Date: Thu Nov 26 2026 - 14:17:22 EST


Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 1

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] This patch makes the per-source tunnel cap compare the full
16-byte union amt_addr endpoint with memcmp() (amt_addr_equal()).
- [Low] The commit message says 'amt_request_handler() and
amt_update_handler() take that snapshot on entry, before…

--

amt: key relay tunnels on a union amt_addr endpoint

This commit stores the relay tunnel endpoint as a union amt_addr instead
of a __be32 and matches endpoints with amt_addr_equal(). It adds
amt_outer_saddr() to snapshot the outer source address and amt_relay_mac()
to compute the Membership Update MAC over the full endpoint.

> amt_outer_saddr() copies the outer source address of a received message
> by value into a zeroed union amt_addr. amt_request_handler() and
> amt_update_handler() take that snapshot on entry, before
> pskb_may_pull() and iptunnel_pull_header() can reallocate the header,

[Severity: Low]
Is this description accurate for amt_request_handler()?

It holds for amt_update_handler(), where amt_outer_saddr() runs before
both pskb_may_pull() and iptunnel_pull_header().

In amt_request_handler(), though, the snapshot is taken after the
function's only pskb_may_pull(), and that handler never calls
iptunnel_pull_header():

if (!pskb_may_pull(skb, sizeof(*udph) + sizeof(*amtrh)))
return true;

amt_outer_saddr(amt, skb, &saddr);

The code itself looks fine. ip_hdr() and ipv6_hdr() are derived again after
the pull, and nothing pulls after the snapshot.

Could the commit message be changed to describe the ordering in
amt_request_handler() correctly?

> diff --git a/drivers/net/amt.c b/drivers/net/amt.c
> index 52ccaca08b5ec..38740e0ace424 100644
> --- a/drivers/net/amt.c
> +++ b/drivers/net/amt.c

[ ... ]

> @@ -3198,7 +3231,8 @@ static bool amt_request_handler(struct amt_dev *amt, struct sk_buff *skb)
> */
> rcu_read_lock();
> list_for_each_entry_rcu(tunnel, &amt->tunnel_list, list) {
> - if (tunnel->ip4 != iph->saddr || READ_ONCE(tunnel->dead))
> + if (!amt_addr_equal(&tunnel->addr, &saddr) ||
> + READ_ONCE(tunnel->dead))
> continue;
> per_src++;
> if (tunnel->source_port == udph->source)

[ ... ]

> @@ -3210,15 +3244,12 @@ static bool amt_request_handler(struct amt_dev *amt, struct sk_buff *skb)
> if (!have && (full || per_src >= amt_max_tunnels_per_src(amt)))
> return true;
>

[Severity: Medium]
Does an exact 16-byte compare still make the per-source cap work on an
IPv6 relay?

amt_tunnel_get_or_create() uses the same exact match before it allocates
a tunnel:

list_for_each_entry(tunnel, &amt->tunnel_list, list) {
if (!amt_addr_equal(&tunnel->addr, saddr) ||
READ_ONCE(tunnel->dead))
continue;
...
if (amt->nr_tunnels >= amt->max_tunnels ||
per_src >= amt_max_tunnels_per_src(amt)) {

amt_max_tunnels_per_src() caps the count at
clamp(max_tunnels / 8, 1, AMT_MAX_TUNNELS_PER_SRC). Its comment says it
limits "the tunnels one verified source address may hold".

On IPv6 this counts per /128. The MAC return-routability check only shows
that the sender can receive at one /128. An ordinary host usually has at
least a /64 routed to it (SLAAC or prefix delegation).

The defaults are a max_tunnels of 128 and 16 tunnels per source. Could one
host run Request -> Query -> Update from eight addresses in its /64, fill
the table, and keep it full by refreshing last_seen? After that, full
would be true here and every legitimate gateway would be refused a Query.
Over IPv4 the same attack needs eight separate IPv4 addresses.

This can't be reached at this commit, since amt_v6() is false. It becomes
reachable later in the series, when "amt: add netlink attributes for an
IPv6 outer transport" adds IFLA_AMT_LOCAL_IP6.

The selftest in "selftests: net: add amt_v6.sh for an IPv6 outer
transport" only checks that two gateways in the same /64 are kept apart.

The commit message only says that the per-source count "compares the
same way".

Would counting per /64 for IPv6 (or per a configurable prefix) keep the
cap doing its job? The cap allows up to 16 tunnels per source, so
separate gateways in one /64 would still be kept apart.

[ ... ]

--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125191450.2497936-1-omar%40blockcast.net