Article View: linux.kernel.netdev
Article #17741[PATCH net] netfilter: ipset: exclude add-path GC during resize
From: onLeaf
Date: Tue, 17 Nov 2026 09:27
Date: Tue, 17 Nov 2026 09:27
56 lines
13215 bytes
13215 bytes
mtype_resize() copies elements to the new table including their extension
pointers. Garbage collection of an expired element in the old table after
the copy therefore frees an extension still referenced by the new table.
Commit cffcf57bf03c ("netfilter: ipset: exclude gc when resize is in
progress") prevents the delayed-work collector from running during resize.
However, mtype_add() also invokes mtype_gc_do() directly when its target
region is full. The packet path can enter this call while a userspace
resize is copying the old table. It then frees the old copy's comment, and
collection of the published copy queues the same object for freeing again.
An unprivileged process can reach packet-side ipset add with CAP_NET_ADMIN
in newly created user and network namespaces. The resulting duplicate free
was reproduced with KASAN on x86-64 and exploited from UID 1000 to UID 0 in
the initial user namespace on a non-KASAN build.
Serialize the direct collector with the same GC lock and honor the pinned
table's resizing flag, just as the delayed-work collector does. The table
remains pinned by uref while the lock is held.
The issue was found through AI-assisted source review. On the fixed kernel,
the same copy/old-GC/publish/new-GC ordering completed without producing a
duplicate object; /etc/passwd remained unchanged and the test ended in
LPE_FAIL.
This change was prepared with assistance from OpenAI Codex.
Fixes: f66ee0410b1c ("netfilter: ipset: Fix "INFO: rcu detected stall in hash_xxx" reports")
Cc: stable@vger.kernel.org
Signed-off-by: onLeaf <onleaf322@gmail.com>
---
net/netfilter/ipset/ip_set_hash_gen.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/net/netfilter/ipset/ip_set_hash_gen.h b/net/netfilter/ipset/ip_set_hash_gen.h
index 80ca523f304b..70f768ba7b44 100644
--- a/net/netfilter/ipset/ip_set_hash_gen.h
+++ b/net/netfilter/ipset/ip_set_hash_gen.h
@@ -1009,8 +1009,12 @@ mtype_add(struct ip_set *set, void *value, const struct ip_set_ext *ext,
maxelem = t->maxelem;
if (elements >= maxelem) {
u32 e;
- if (SET_WITH_TIMEOUT(set))
- mtype_gc_do(set, h, t, r);
+ if (SET_WITH_TIMEOUT(set)) {
+ spin_lock_bh(&h->gc.lock);
+ if (!t->resizing)
+ mtype_gc_do(set, h, t, r);
+ spin_unlock_bh(&h->gc.lock);
+ }
maxelem = h->maxelem;
elements = 0;
for (e = 0; e < ahash_numof_locks(t->htable_bits); e++)
--
2.43.0
Technical Details
Message-ID:
<20261117092731.14656-1-onleaf322@gmail.com>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365107-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365107-linux-kernel-netdev=dewy.ru
From: onleaf322@gmail.com (onLeaf)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] netfilter: ipset: exclude add-path GC during resize
Date: Tue, 17 Nov 2026 18:27:31 +0900
Organization: Usenet Network
Message-ID: <20261117092731.14656-1-onleaf322@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="2291267"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:H78MoJ1ZhmJ3JoIRcK6I8uu7Clo= sha256:iW2uUEX63/gzS2sCkrI3MRwLyGHaPLuPn4ApTtpamqM=
sha1:fS+bgEnnyH9zwmFzwO+rUKb6ln8= sha256:MnLevpzT0ZeFWqug+4NaUXWTXdjh2b5isHe2QgAciXc=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 14111114EC5; Tue, 17 Nov 2026 12:28:03 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id 3C079Opwyb8f;
Tue, 17 Nov 2026 12:28:00 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-365107-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id AC274114EC4; Tue, 17 Nov 2026 12:27:51 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id 493B627FD9; Tue, 17 Nov 2026 09:27:44 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1794907664;
b=qGlWt0HBXRRAFV0GjGtcbLCgFsH2NVQCkA4ZhefmvV+YN1yI5wXdeREiiT/joYw28OBa
SAiodLwd6T4GaRcYWKKCIWWQCKXWHuLBUZ/azBFNmnNTwv1o8LfGK3YKG8B6Y+WsUdOZ+
HuIiojota91qdGefu45GT0/2qJGYq7e/bDIwG+yCRNlFq8Um2muNMmwdcK7OR+xgUoT9V
SulqVNR7dGYdppyXGnorfN9LDSHnt2KNLnF1mlNOE98VXvSQfenTGbv4KPhrYTIfCjkRR
Dqu2GVTxnIkZyRKGK/KNqwhyumJDsOA41/P19SX74HMD0mmtDxZuhNZRWMmj++0wTbA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794907664;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:Date:Message-ID:
X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Transfer-Encoding;
bh=aDSdHKsmTGGWkDOKCvZtMPEPFRR2Z2wRDeQx9ZQTN3o=;
b=4+nAosX+ev/9k8UPUXoCi3fEreSs6WY16yU9c29kEH1qByVSlFr/GtJP/sqAlJpn9oYm
noBt4GohTQz9qaUnNIWbz6IPvBu7nedvT1vOKHpqzrLUUcjSfbx1TMmc4UL6KnJi5+mm5
wasiEWdqjY9EHC3yPA2DHn7dPcGvu0ncbPbv8V0kdnE+oORrH8UQQ9i51X+/lx+yS7KAu
fNHBlxp2rFoVyTI/aczka8S8EvWtefGg6Ba5YHH//7oLqGo4MylKY3ELuCPf7mvYwUmtq
Y9XMyXtYxsr/JpZnkg5dmx+IPxcdJj5J1sUKoohR74ZlWax/ylVLW8WyPqyIv0VayNw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="0SeRLO/C";
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id E2051606A329;
Tue, 17 Nov 2026 09:27:43 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=0SeRLO/C
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.229.131
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1794907663;
b=sGNgZhl0X6DekK5OBPRmp0VBy8WDWpJPzV0dn6IjmBPT6TsgAVRk/Q7dKv/ZF0Bvkdup
Cnlz2cBv0HzLnEqGkgNEH92XHfQ9jtw6IlloRKXchCDuxDTMI18tCdGdO6RBVQ4OnsnSb
Dw4aTRsL3RetYR5TKN//vFKpM/c3vzjnqxJzQ+jg286AgPiKrcEKmwYgcMgDN4aH9886t
H+pY/7Pdrnnilb2AxSMG891nGYWRwGcgvWhHV89X74gfvjof6SebJld6rauDH5LCW4Nty
HIMzFgPy5zOPEnh8kGUrVFfyl1F027JhyD4EuUUp+cil3/TWbpMV9fM2boRRqhdKLrA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794907663;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version:
Content-Transfer-Encoding;
bh=aDSdHKsmTGGWkDOKCvZtMPEPFRR2Z2wRDeQx9ZQTN3o=;
b=MmoXSmODA0XAMD1Mnc0gU6WlBoF4mINESv24QI6dZRkoXZidPEygDDEWwM5Oci2bIbJu
UbKuMlM06vT+48nVF9/50EeYhiKW8ms44LIsxAtj9PBm1t4uTTFjb3DUH1Oy5mvnA+TOk
ETucGFRvq2rUVEEJtGFjzX8Ys97lSX9591tZO35OoA5fzZ9Q2NEKGoSpiWrFwZf7jAWR3
zDuteQ3kVj06RCbjwvLkNb9QgquN82dvLRWhCiYZcYHJpA0mWgOw/3hcOVlsyVi+gn5KL
shNoSBkR4Dr6FDw13qyjGpmEFySAKTWYQpfwlkDUO7NHTuvydwjtTz430TtpD3i4M6w==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="0SeRLO/C";
arc=none smtp.remote-ip=74.125.229.131
X-Received: from mail-dl2-f3.google.com (mail-dl2-f3.google.com [74.125.229.131])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F3F9606A32A
for <netdev@vger.kernel.org>; Tue, 17 Nov 2026 09:27:42 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4F3F9606A32A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-dl2-f3.google.com with SMTP id a92af1059eb24-1521c45a248so3040298c88.0
for <netdev@vger.kernel.org>; Tue, 17 Nov 2026 01:27:42 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1794907661; x=1795512461; darn=vger.kernel.org;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:from:to:cc:subject:date:message-id:reply-to:content-type;
bh=aDSdHKsmTGGWkDOKCvZtMPEPFRR2Z2wRDeQx9ZQTN3o=;
b=0SeRLO/Cu/Z7fD38T1aAPibopqP6aQGUmhp1Bo9C+KNJ0zCPPS4ridEDVsmduTWVMB
IcSiChIYc5OtxT7LxawZZwt+I4vRJx+Vqq/qgo8Z8FQoveqYdA9YRJcwE/sXvxSDpMRr
xicb0QeRwgjZ9gDwefSkUvHASJVJQlsYzMLlQ4EAKa7se1CKQDlqSiZO4Xwi4Wnc/QC2
VNJwxXOQsdQW6+6QcfmItcKP+zjvb/hOjtnhCrZe6LlBjJf4dHf/HEeX6Tndo67/JG2A
sGSH6TS8rkRN0Xbzr2uiSUXWh7FLBkPXcSgHu7bfSdxyrlnkvQ/DQ6n04bjGVmj+umb1
eyZg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1794907661; x=1795512461;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=aDSdHKsmTGGWkDOKCvZtMPEPFRR2Z2wRDeQx9ZQTN3o=;
b=q+8NzXyvLw8RzJtoYMqiXoivN2e4na1w9tTe5sZsxJ/C/2RN1DyS0ZKluAiw9f1nVN
tRP7lTuPPLa/XvFzoKzKe1XAlRHRlycaIuktSadoqU0HDpRSsbTQAYNYWNOjAIhcPtLV
VvcOG3mON9YG+hSF3vugqt3jtbbRE4D7Pq/EdYPT3nFbap+tT3h9yi6Gb3y7szi9bhoZ
0C7lQfMURkrG5f9dejcgQOvzYStD1CoT8XofdJTMXXixELAPmhif8y7qH6d+GODwTpj3
tUldjpMMSDNh1mfYiX4h6kxIvojdRV/LMQDvZtPcdazeuhnIFgsRPe6lVFwQGSQtf/0u
ZjkQ==
X-Forwarded-Encrypted: i=1; AL+hErEn7yNtjXiIMI4ShWPVAJMckyrfgUYoVgqntcpSbpAPJk6H0dWQSNxsimxy8YgB2Jgjfbv134I=@vger.kernel.org
X-Gm-Message-State: APuU4Z/LdQ4HjOd/tVaSYJCZgbza3CAADlErkC+ziQ5+bJ0/0yDKb4Dj
MZZeTn5h2vXG+t1J7QtUud6MsoqoQdEifbzsnSzAPTIoj6uNHfR5HQhw
X-Gm-Gg: AYBFou0yoT2hRLixjf2mAMBoRImsQgm/IXbFM6px6ijpXCDJG2LPvz1kY/OOPn67VgY
T2VlD88oJsoLR8/T94V2DriJq8X7trRIQQWOTH4LqmLi3OeuDNMnuKw6gChpkedTzFy47z8HniQ
14bnFGgKXFrFipYta/7+G8HKySbFrV+C5RKG8Qh8X0Fb8AX2tBgXaaHwCFKfdZi3BHHKZMmqSxr
5b0/1QcE/3m4CQn/XfAPuBBcLHnc003aVgXn8oqeWO/ZIPqpY5RvbgwGMfdzBg5QRIIEe3o0LTJ
Own3HjK4W6KF7Cm1WXJHy/HxVJqjwDiXWH/qN8fqvD2dkC/SItboPShqLwLPGu1vP6oCWo3CXy5
eAhrakJ/NO9275mdUEhvnFAUF2xb0y2gn9qEEWew6BAugE8CMhFf3qt4KqmzDv73IBoEKDTptJb
5IYVl9+YxL1N0aOCBw9lEMncTXUf8AgVZ9c4SVmW+vgdjS4Me1gY8ZOkhRTb38yWThvluQLp2Vj
6YZBb/wKw1teYG36vNl0o0bLCaOg++Gz+/ueKdTmlf3lkqXvBkmmVI0E2HsAX/Gm4TXm39SJbZl
VmW9WmOu1IDeyVP9PtFz1LnGT3CHEWI9HjflcRpELjGAdvefaMHdSGX8ljQauPDY6heOA7NAgES
WQA==
X-Received: by 2002:a05:7022:438e:b0:1b2:539b:496c with SMTP id a92af1059eb24-1b503175d03mr21231997c88.35.1794907661127;
Tue, 17 Nov 2026 01:27:41 -0800 (PST)
X-Received: from DESKTOP-GSNRJ5L.tail4a8ad8.ts.net ([104.28.223.11])
by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b50309b27dsm38381531c88.2.2026.11.17.01.27.35
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Tue, 17 Nov 2026 01:27:40 -0800 (PST)
X-Cc: phil@nwl.cc,
kadlec@netfilter.org,
davem@davemloft.net,
edumazet@kernel.org,
kuba@kernel.org,
pabeni@redhat.com,
horms@kernel.org,
netfilter-devel@vger.kernel.org,
coreteam@netfilter.org,
netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
onLeaf <onleaf322@gmail.com>,
stable@vger.kernel.org
X-Mailer: git-send-email 2.43.0
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list