From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 834F447F2CE; Thu, 20 Aug 2026 17:56:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787248595; cv=none; b=BlqnU0pXXzjwBSYLRJq3iJVYVz9CGNTEwyoxX2I7Au5UsVu9uO9h+6NsYWKjfc8dT7tlJEtKXmGcumF2EKYrwri1RdmXAHVBXRiviOXGWuhnM+0Vn1OO3dRO5L9NoghACBIOiwzZWivAd7rDQWLxqSk5Xbxo+2UyfWsgQEYK2jg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787248595; c=relaxed/simple; bh=MpGXaz53oNHTcCjzb/ATIC1hMgEM8XZJdJwn0F/WLf4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hLtFoBXxX2P2DAgjLtOomKLpvYggspdKqfCL4MTqcxyZ4q62GdFYFBJnf2W5/Q9Vi0yLVifQLsplXfqLmPXSdrAijXm0JHpWbWMk3vgSGz/rNgCuTYw6CDQFF7fE16NAXPmsUj+ERCJdvi3X8NuC7TnL/zNQziFzI/lpRvT8FGA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ISNeFuMP; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ISNeFuMP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D58301F000E9; Thu, 20 Aug 2026 17:56:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1787248594; bh=sabQWwENEq4fxiFqHlCF3BfRxP8irDQ3Q22alprqQKE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ISNeFuMPP+F6/O32oFK8dAYJAcFmIJ5zqylgVbLNGu2uJLcq+NmSaQv581vO+2qv7 x/fyAKYuStXfIDEZ/cf22mZ9/cTSaLsB5gRw7STwOzixtDnE/8QQpnzvVJwqerbisd t7wjjhXBsF5fXcZovpp1QxUYIvs2ZDMA/XSx+66M= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jozsef Kadlecsik , Florian Westphal , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 6.1 283/303] netfilter: ipset: let destroy callbacks adjust ext mem size Date: Thu, 20 Aug 2026 16:56:59 +0200 Message-ID: <20260820145301.971450944@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260820145253.200766705@linuxfoundation.org> References: <20260820145253.200766705@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Florian Westphal [ Upstream commit 490937b88cb592cc0c5367758edd700fd5abd15c ] For bitmap this change makes no difference, because destructors are called synchronously. List type however calls them via call_rcu() so accounting decrement can happen after list_set_flush() set ext_size to 0. 'set->elements = 0' can be removed for the same reason in the list type case, it calls 'set->elements--' for each element. Fixes: 9e41f26a505c ("netfilter: ipset: Count non-static extension memory for userspace") Suggested-by: Jozsef Kadlecsik Signed-off-by: Florian Westphal Acked-by: Jozsef Kadlecsik Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/ipset/ip_set_bitmap_gen.h | 2 +- net/netfilter/ipset/ip_set_list_set.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/net/netfilter/ipset/ip_set_bitmap_gen.h b/net/netfilter/ipset/ip_set_bitmap_gen.h index 40f0383883f9d..605d54d2bd7e6 100644 --- a/net/netfilter/ipset/ip_set_bitmap_gen.h +++ b/net/netfilter/ipset/ip_set_bitmap_gen.h @@ -75,7 +75,7 @@ mtype_flush(struct ip_set *set) mtype_ext_cleanup(set); bitmap_zero(map->members, map->elements); set->elements = 0; - atomic64_set(&set->ext_size, 0); + DEBUG_NET_WARN_ON_ONCE(atomic64_read(&set->ext_size) > 0); } /* Calculate the actual memory size of the set data */ diff --git a/net/netfilter/ipset/ip_set_list_set.c b/net/netfilter/ipset/ip_set_list_set.c index 848fbafd2593d..139df33149119 100644 --- a/net/netfilter/ipset/ip_set_list_set.c +++ b/net/netfilter/ipset/ip_set_list_set.c @@ -423,8 +423,7 @@ list_set_flush(struct ip_set *set) list_for_each_entry_safe(e, n, &map->members, list) list_set_del(set, e); - set->elements = 0; - atomic64_set(&set->ext_size, 0); + DEBUG_NET_WARN_ON_ONCE(set->elements > 0); } static void -- 2.53.0