🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
1 messages
1 total messages Started by netdev-bot+sashiko Mon, 30 Nov 2026 03:48
Re: [PATCH net-next v4 02/12] amt: send the Relay Advertisement over IPv6
#24361
Author: netdev-bot+sashiko
Date: Mon, 30 Nov 2026 03:48
123 lines
12561 bytes
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] In the new IPv6 Discovery path of amt_discovery_handler()
  (drivers/net/amt.c), the only filters are a multicast outer…

--

amt: send the Relay Advertisement over IPv6

This patch adds the 24-byte IPv6 form of the Relay Advertisement and a
new amt_send_ctrl_v6() helper, which routes through amt_route6() and
sends with udp_tunnel6_xmit_skb(). On an IPv6 device,
amt_discovery_handler() now answers a Discovery with this form. The
reply is sourced from the Discovery's outer destination and sent back
to its outer source and UDP source port.

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

[ ... ]

> @@ -3026,6 +3118,29 @@ static bool amt_discovery_handler(struct amt_dev *amt, struct sk_buff *skb)
>  	if (amtd->reserved || amtd->version)
>  		return true;
>  
> +	/* The Advertisement takes the form of the outer IP version, and
> +	 * RFC 7450 s5.1.2 sources it from the address the Discovery was
> +	 * sent to, which may be an anycast Relay Discovery Address rather
> +	 * than local_ipv6.
> +	 */
> +	if (amt_v6(amt)) {
> +		struct in6_addr saddr = ipv6_hdr(skb)->saddr;
> +		struct in6_addr daddr = ipv6_hdr(skb)->daddr;
> +
> +		/* The socket bound to :: also receives a Discovery sent to
> +		 * a group, and a multicast address can never be a source
> +		 * (RFC 4291 s2.7), so such a Discovery is not answered. Nor
> +		 * is one from ::, which has nowhere to be sent.
> +		 */
> +		if (ipv6_addr_is_multicast(&daddr) ||
> +		    ipv6_addr_any(&saddr))
> +			return true;
> +
> +		amt_send_advertisement_v6(amt, amtd->nonce, &daddr, &saddr,
> +					  udph->source);

[Severity: Medium]
Will a Discovery whose outer IPv6 source is one of the relay's own
addresses still be answered here? The only filters are a multicast
destination and a :: source. The outer saddr and udph->source then
become the destination address and port of the reply.

A remote sender that can forge the source address (on the same link, or
on a path without BCP38) could send a Discovery to relay_port. It would
set the source to local_ipv6 or the link-local address of stream_dev
(for example with saddr == daddr), pick a UDP source port P, and choose
the nonce. The reply would then take this path:

amt_discovery_handler()
  amt_send_advertisement_v6(amt, nonce, &daddr, &saddr, udph->source)
    amt_send_ctrl_v6()
      amt_route6()
        ip6_dst_lookup_flow()    <- local route for a stream_dev address
      udp_tunnel6_xmit_skb()     <- delivered back to the host over lo

The host would send itself a 24-byte datagram from
<local addr>:relay_port to <local addr>:P. The 4-byte nonce in it is
chosen by the sender. The datagram arrives with iif=lo, so common rules
such as "-i lo -j ACCEPT" (ufw and firewalld defaults) would let it
through. It could then reach local UDP services bound to :: or to that
address, which the sender cannot reach directly.

The IPv6 input path doesn't seem to stop this. It only rejects loopback
and multicast sources:

net/ipv6/ip6_input.c:ip6_rcv_core() {
    ...
	if ((ipv6_addr_loopback(&hdr->saddr) ||
	     ipv6_addr_loopback(&hdr->daddr)) &&
	    !(dev->flags & IFF_LOOPBACK) &&
	    !netif_is_l3_master(dev))
		goto err;
    ...
	if (ipv6_addr_is_multicast(&hdr->saddr))
		goto err;
    ...
}

On IPv4, fib_validate_source() treats a local source as martian by
default (accept_local=0). That is why the existing
amt_send_advertisement() path is not exposed in the same way.

amt_discovery_handler() and amt_rcv() still have only these checks at
the end of the series. The path becomes reachable once "amt: add
netlink attributes for an IPv6 outer transport" allows an IPv6 outer
address to be configured.

Would it make sense to drop a Discovery whose outer source is a local
address, for example with ipv6_chk_addr(amt->net, &saddr, NULL, 0) or a
check on the route type? At minimum, could a Discovery with saddr equal
to daddr be dropped?

> +		return false;
> +	}
> +
>  	amt_send_advertisement(amt, amtd->nonce, iph->saddr, udph->source);
>  
>  	return false;

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

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads