Netdev List
 help / color / mirror / Atom feed
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,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	horms@kernel.org
Subject: Re: [PATCH net-next v4 2/3] amt: bound the source-state work of one Membership Update
Date: Sat, 28 Nov 2026 21:28:41 +0000	[thread overview]
Message-ID: <179590132102.3135.11903676498042609823@kernel.org> (raw)
In-Reply-To: <20261124210501.70394-3-omar@blockcast.net>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] This patch closes a CPU-exhaustion problem that a remote host can
  trigger in the AMT relay, but it carries no Fixes: tag and is not…
- [Low] The new comment above AMT_REC_WALKS/AMT_REC_LOOKUPS in
  include/net/amt.h (lines ~395-400) says the constants bound "the…
- [Low] amt_rec_cost() (drivers/net/amt.c:2164-2168) assumes every pass
  may walk hash_buckets + nr_sources + nsrcs nodes, i.e. that…

--

amt: bound the source-state work of one Membership Update

The patch charges each IGMPv3/MLDv2 group record in a Membership Update
for the walks and lookups it causes. It stops applying records once the
total exceeds twice the cost of refreshing the tunnel's whole state.
Records for groups the tunnel has no room for are skipped and not charged.

> Found by review (Sashiko, on the limits patch); not triggered at runtime.

[Severity: Low]
Should this carry Fixes: tags and be routed through net as a bug fix?

Before this patch, amt_igmpv3_report_handler() and
amt_mldv2_report_handler() applied every record under tunnel->lock in
softirq. The only bound was ip_mc_may_pull()/ipv6_mc_may_pull().

Any host that completes the Request/Query exchange gets a valid response
MAC. It can then send a reassembled Update of up to about 64 KB with
roughly 8000 empty records naming one group. Each record makes several
full passes over the group's 256 buckets: the amt_lookup_act_srcs() passes
plus the two in amt_cleanup_srcs().

The loops date back to:

Fixes: bc54e49c140b ("amt: add multicast(IGMP) report message handler")
Fixes: b75f7095d4d4 ("amt: add mld report message handler")

Without these tags, stable kernels keep the length-only bound. The
"not triggered at runtime" line also doesn't say that the issue can be
reached remotely. The earlier patch "amt: make the A-B source walk linear"
has the same gap.

> diff --git a/drivers/net/amt.c b/drivers/net/amt.c
> index 79d68bcc7ccfd..177bc0b7cb1fd 100644
> --- a/drivers/net/amt.c
> +++ b/drivers/net/amt.c
> @@ -2157,6 +2157,30 @@ static void amt_igmpv2_leave_handler(struct amt_dev *amt, struct sk_buff *skb,
>  		amt_del_group(amt, gnode);
>  }
>  
> +/* The source-state work one group record can cause: AMT_REC_WALKS passes
> + * over the group's buckets and sources, which add_srcs may grow by nsrcs,
> + * plus AMT_REC_LOOKUPS hash lookups per record source.
> + */
> +static u64 amt_rec_cost(const struct amt_dev *amt, u32 nr_sources, u16 nsrcs)
> +{
> +	return (u64)AMT_REC_WALKS * (amt->hash_buckets + nr_sources + nsrcs) +
> +	       (u64)AMT_REC_LOOKUPS * nsrcs;

[Severity: Low]
Does the walk term over-charge sources the relay will refuse?

The term assumes amt_add_srcs() can grow the group by the full nsrcs.
However, amt_add_srcs() stops once the tunnel is full:

drivers/net/amt.c:amt_add_srcs() {
    ...
	for (i = 0; i < nsrcs; i++) {
		if (tunnel->nr_sources >= amt->max_sources)
			return;
    ...
}

So a walk never visits more than hash_buckets + max_sources nodes.
Refused sources already pay their lookup cost through AMT_REC_LOOKUPS.
They are also charged AMT_REC_WALKS units each for walk growth that cannot
happen.

The charge and the break run before amt_add_group(), amt_add_srcs() and
the mode handlers. At the defaults, the budget is 120320 and a new-group
record costs 1792 + 15 * nsrcs. A first record with more than about 7900
IPv4 sources therefore trips work > budget at i == 0, and none of the
Update is applied.

Smaller spreads get cut early too. For example, 32 records of 160 sources
are charged about 134k, while the real worst-case work is about 99k.

Normal hosts split reports to the MTU, so this needs MTUs above roughly
16 KB, or a sender that only damages its own state.

The commit message says "records the relay refuses cannot use up the
budget". That rule is applied to groups but not to sources. Would capping
the nsrcs inside the walk term at the remaining room
(max_sources - tunnel->nr_sources) match the growth that can actually
happen?

> +}

[ ... ]

> diff --git a/include/net/amt.h b/include/net/amt.h
> index f36efcdd92d0b..82aaa6b3070fb 100644
> --- a/include/net/amt.h
> +++ b/include/net/amt.h
> @@ -392,6 +392,14 @@ struct amt_dev {
>  #define AMT_GC_KICK		2048
>  #define AMT_MAX_GROUP		32
>  #define AMT_MAX_SOURCE		128
> +/* Per group record, an upper bound on the passes the mode handlers plus
> + * amt_cleanup_srcs() make over a group's buckets and sources, and on the
> + * hash lookups they make per record source.  The handlers need at most 5
> + * and 7 (EXCLUDE TO_IN and EXCLUDE BLOCK); the bound is rounded up so a
> + * later pass does not silently exceed it.  See amt_rec_cost().
> + */

[Severity: Low]
Does the count of 7 lookups per source match the functions this comment
names?

In amt_mcast_block_handler(), the EXCLUDE branch calls
amt_lookup_act_srcs() with AMT_OPS_SUB_REV, AMT_OPS_UNI, AMT_OPS_SUB_REV
and AMT_OPS_UNI. That is 6 lookups per source. amt_cleanup_srcs() makes no
per-source lookups.

The seventh comes from amt_add_srcs(), which runs before every mode
handler:

		if (amt_lookup_src(tunnel, gnode, AMT_FILTER_ALL, &src))
			continue;

amt_add_srcs() is not listed here. The amt_rec_cost() comment mentions it
only as growing the source count.

The constants are still valid upper bounds today. Someone re-deriving the
bound from the listed functions would find 6 lookups and assume 2 of
headroom under AMT_REC_LOOKUPS, when the real headroom is 1. Could the
comment list amt_add_srcs() as a contributor?

> +#define AMT_REC_WALKS		7
> +#define AMT_REC_LOOKUPS		8
>  #define AMT_HSIZE_SHIFT		8
>  #define AMT_HSIZE		(1 << AMT_HSIZE_SHIFT)

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

  reply	other threads:[~2026-11-28 21:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 21:04 [PATCH net-next v4 0/3] amt: configurable per-tunnel limits, with bounded report work Omar Ramadan
2026-11-24 21:04 ` [PATCH net-next v4 1/3] amt: make the A-B source walk linear Omar Ramadan
2026-11-24 21:05 ` [PATCH net-next v4 2/3] amt: bound the source-state work of one Membership Update Omar Ramadan
2026-11-28 21:28   ` netdev-bot+sashiko [this message]
2026-11-24 21:05 ` [PATCH net-next v4 3/3] amt: make the per-tunnel group and source limits configurable Omar Ramadan
2026-11-28 21:28   ` netdev-bot+sashiko

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=179590132102.3135.11903676498042609823@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=netdev@vger.kernel.org \
    --cc=omar@blockcast.net \
    --cc=pabeni@redhat.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