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=1793210624; b=wU5DL/xKFjeky7mKJSPCJ/bJbCSpBn9fiayDFxKM/wKaxTSPQ1R5EgmKvBChV1xY+Zkl wslxN7z+9r5U0AcCiQmChd5LTgarhBkiZK644sUqRzefvHdXEluEtI7dGXbIMuNl+bqN2 SjXAw+O/M6hxpcqNWYa8Dm3cmNyjvEnzImvKgqTbqDjY6SkJ5iS5q2WUrGMNRV72xw/JX +Gf9dVcSDhWOCpsNVyOv2YECuSK3ez10t/qg88KxhRFAHE3154SGF2KCDGfvBpWr1h4RM XpfLlpEhW7k7YHUGwZwEk3DQljOyyxYJkbmtpQIGo6Bj3JRcngQ1rrfqNKFmIRajboQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793210624; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=CqHcEoMhAOGdcJe3OnLWvGp5mXmjefOD+BM3o11NTQo=; b=MEaIVvrmIDGA0s96/2oF3p+3/Ffr/PO2axjx4KMPAl3vTAxrW9wxuJ/py8IYFvg5Qy4H GB/wwkHSzTfwfxL+rZo/haZcxn5+CRb6PP838BCl0h8/mUDXq4MEWBaniBBIsrgb4PQIm mBO6wnqcmz56HGv9g4C998ifOxV1xRY7wZ1MbeRTTp+tt6BLxJr1Z4shql0ca/X1lXK24 iHwWFczo2uZmIbnxDI45wGKx4Pktx5usqZ9jJhP90pJouZmPymXA2KlsTjDNW++ga9lII ofk896HBQ9ZB/u4nvOK8THll+cNuGPQmt4RpOvZPxrzjug1BdVgRW39eWuMRH+LoXHg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=lhHZwYLG; 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 BB627606A31E; Wed, 28 Oct 2026 18:03:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=lhHZwYLG Received: by smtp.kernel.org (Postfix) with ESMTPSA id 153651F01825; Wed, 28 Oct 2026 18:03:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1793210623; bh=CqHcEoMhAOGdcJe3OnLWvGp5mXmjefOD+BM3o11NTQo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lhHZwYLG/cU6UlUb8hu98WyNvJLxlOULjU6pBf4Ap9U6iClhGMTes2+vbitJzWN4V My/1JKtaWX4jgKfORoaW6fdBYX0GyjS47wN03dvyXMFm92qCJU89Wy+y2q8QnA75Gc 4VfaAurYIbOwIZgbVyjZHFP9teN1f9jgKrqmX3Wk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Vega , Zihan Xi , Ido Schimmel , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 092/571] ipmr: account multicast table and route memory Date: Wed, 28 Oct 2026 17:53:59 +0100 Message-ID: <20261028170010.207329819@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261028170008.009143722@linuxfoundation.org> References: <20261028170008.009143722@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zihan Xi [ Upstream commit b7ee18725f2292ab554aa96a101ae42d45f008bd ] A netadmin in a user+net namespace can create many IPv4 and IPv6 multicast routing tables with MRT_TABLE and MRT6_TABLE. Each unseen id allocates an mr_table via the shared mr_table_alloc(), links it into the per-net list, and leaves it until netns teardown. Those objects were not charged to memcg, so the host unreclaimable slab grows with the table count. Account mr_table allocations with GFP_KERNEL_ACCOUNT and mark the IPv4/IPv6 MFC caches SLAB_ACCOUNT. This matches the established handling of IP addresses, routes and alternate interface names. Unresolved MFC entries are still allocated from softIRQ with GFP_ATOMIC and are not charged. They expire after 10 seconds and are bounded by the socket receive queue; see commit 0079ad8e8dc3 ("ipmr: remove hard code cache_resolve_queue_len limit"). Fixes: f0ad0860d01e ("ipv4: ipmr: support multiple tables") Fixes: d1db275dd3f6 ("ipv6: ip6mr: support multiple tables") Cc: stable@vger.kernel.org Reported-by: Vega Signed-off-by: Zihan Xi Reviewed-by: Ido Schimmel Link: https://patch.msgid.link/050b58f7fc6b45da0fb12768ebb62d18fa46133d.1788784801.git.zihanx@nebusec.ai Signed-off-by: Jakub Kicinski [ adapted upstream allocation helpers to existing kzalloc() and kmem_cache_create() calls. ] Signed-off-by: Sasha Levin --- net/ipv4/ipmr.c | 3 ++- net/ipv4/ipmr_base.c | 2 +- net/ipv6/ip6mr.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c index 5e582eab1ea19..d5ae2df481a48 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c @@ -3115,7 +3115,8 @@ int __init ip_mr_init(void) mrt_cachep = kmem_cache_create("ip_mrt_cache", sizeof(struct mfc_cache), - 0, SLAB_HWCACHE_ALIGN | SLAB_PANIC, + 0, SLAB_HWCACHE_ALIGN | SLAB_PANIC | + SLAB_ACCOUNT, NULL); err = register_pernet_subsys(&ipmr_net_ops); diff --git a/net/ipv4/ipmr_base.c b/net/ipv4/ipmr_base.c index 8b5b6f196cdc4..fb9796e21074f 100644 --- a/net/ipv4/ipmr_base.c +++ b/net/ipv4/ipmr_base.c @@ -38,7 +38,7 @@ mr_table_alloc(struct net *net, u32 id, struct mr_table *mrt; int err; - mrt = kzalloc(sizeof(*mrt), GFP_KERNEL); + mrt = kzalloc(sizeof(*mrt), GFP_KERNEL_ACCOUNT); if (!mrt) return ERR_PTR(-ENOMEM); mrt->id = id; diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index 909a2bc2a020d..a793dcd24813e 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c @@ -1357,7 +1357,7 @@ int __init ip6_mr_init(void) mrt_cachep = kmem_cache_create("ip6_mrt_cache", sizeof(struct mfc6_cache), - 0, SLAB_HWCACHE_ALIGN, + 0, SLAB_HWCACHE_ALIGN | SLAB_ACCOUNT, NULL); if (!mrt_cachep) return -ENOMEM; -- 2.53.0