From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795901322; b=JkVBUbeVheJHOF46WxVnAxTlWi5vSFCCZhf143u+/urJ/CmMgLYMezrfZ4PZQtJpkYwD 5NSzBOH65uixMHePF3191OouIyhkFGhkbjs/AL6G6Mxabn4ARWcbrW34E8zwtG7lM94lt dQaCZopgoSRpk1PtjFFMSFjXmMzcTXXpl5kgp511ZOmZ+X8i74tQ39HMvhOK6hidNZd6M v9wllGyFz70vlQsxT1ruL07lstbTPqD1C+r2ig6rbsi9roaai/w+Z6v0FNNF219gm6Z7P pFa+tmQsmbVOIOhhijJjvRwdPRH7lKbhq4hIqEjPolmyXQKh6P9EyBcFGKlG+X/MmGg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795901322; 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=ielV6tM/52wXULSXTeUVRzuABqzYUW8PnNdu+mfFnRE=; b=22jn2cnNo9GcH07HgLCF2k4n0zeuH/gywBYfup9o0UmQTEMvVv9+UVgTAubWfsmT3nHv mMl8d3zvtvfHq1fKNFeJTbearDSam2koby+1w7GB3ygW2FhT2Adk6MvNKw3yapcs9w2KG bVvxoVnEXNwv673E/m5tM2JHO2BS8S5zVgwUDRhi92oAeGMw9KzXE7Jlb/EMyWWMxA9jP pEGDNTdCvk1Nsaduz8xfn36J7eHrxAb+wc8OiGhqK+f9HpcOiw8mXLrnE84bZaarLvOrc nva+F074U4sIvf10zrfHNzZ9zrkJDa5vFIgmeMXZMIEBfXZOtnYufN1ENsC2g25odUg== 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=YTWSz1tB; arc=none smtp.remote-ip=100.103.45.18 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 622E7606A323; Sat, 28 Nov 2026 21:28:42 +0000 (UTC) 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=YTWSz1tB Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77CFC1F00899; Sat, 28 Nov 2026 21:28:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795901322; bh=ielV6tM/52wXULSXTeUVRzuABqzYUW8PnNdu+mfFnRE=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=YTWSz1tBCM41SZnKyFSvxlNt4Y3sh1V/H7HjEgGqBAG7PbHeJVa+iXSnZHSsXmc3V 4HrEmxNsN+Y/K+LOifOo4XzvWvGLTNFkMAaciK4MnilEmi08JH3DwDudGe/HwQ3qvJ wr0YPiGyNGh15b1Utt6vV1I6LtPydQSJlB9gQEW1aKZmGqMYkxXzO73p3PxYvOE1Hl Gkgbd4tAzqMGla/kwiVMe++pNeIzt+2cPy6pMcwIWecAWsHjNMTel1j7BRIwcw8ttX 7s2KuERgRPs64ccy4wJ6phsq5wR5xyHnHcQZYTLPcy6m/pJb7HIZ0t3yyX+6FLOnY6 QzSci1ppIwLZw== Subject: Re: [PATCH net-next v4 2/3] amt: bound the source-state work of one Membership Update 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 Date: Sat, 28 Nov 2026 21:28:41 +0000 Message-ID: <179590132102.3135.11903676498042609823@kernel.org> In-Reply-To: <20261124210501.70394-3-omar@blockcast.net> References: <20261124210501.70394-3-omar@blockcast.net> X-sashiko-severity: Low Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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