Article View: linux.kernel.netdev
Article #20229[PATCH nf] netfilter: ipset: fix extension leak during hash resize
From: Ömer Mete Kaya
Date: Sat, 21 Nov 2026 21:15
Date: Sat, 21 Nov 2026 21:15
46 lines
12578 bytes
12578 bytes
During hash table resizing, mtype_resize() skips expired elements
without freeing their extensions. The old table is then destroyed
with ext_destroy=false, so these extensions are never freed.
Fix this by calling ip_set_ext_destroy() on expired elements in the
resize copy loop. The cleanup is done under the region lock with the
bucket re-read into a separate variable to avoid races with
mtype_add() concurrently reusing or reallocating the bucket, while
preserving the original bucket pointer for subsequent loop iterations.
Discovered by Sashiko, not triggered, not runtime tested.
Fixes: 80571a9ea4ca ("netfilter: ipset: Fix hash resizing with comments")
Signed-off-by: Ömer Mete Kaya <omermetekaya0@gmail.com>
---
net/netfilter/ipset/ip_set_hash_gen.h | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/net/netfilter/ipset/ip_set_hash_gen.h b/net/netfilter/ipset/ip_set_hash_gen.h
index 80ca523f304b..47aab02c9d23 100644
--- a/net/netfilter/ipset/ip_set_hash_gen.h
+++ b/net/netfilter/ipset/ip_set_hash_gen.h
@@ -823,8 +823,19 @@ mtype_resize(struct ip_set *set, bool retried)
if (!test_bit_acquire(j, n->used))
continue;
data = ahash_data(n, j, dsize);
- if (SET_ELEM_EXPIRED(set, data))
+ if (SET_ELEM_EXPIRED(set, data)) {
+ struct hbucket *cur;
+
+ spin_lock_bh(&orig->hregion[r].lock);
+ cur = __ipset_dereference(hbucket(orig, i));
+ if (cur && test_bit(j, cur->used)) {
+ data = ahash_data(cur, j, dsize);
+ if (SET_ELEM_EXPIRED(set, data))
+ ip_set_ext_destroy(set, data);
+ }
+ spin_unlock_bh(&orig->hregion[r].lock);
continue;
+ }
#ifdef IP_SET_HASH_WITH_NETS
/* We have readers running parallel with us,
* so the live data cannot be modified.
--
2.56.0
Technical Details
Message-ID:
<20261121212037.149722-1-omermetekaya0@gmail.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368463-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368463-linux-kernel-netdev=dewy.ru
From: omermetekaya0@gmail.com (Ömer Mete Kaya)
Newsgroups: linux.kernel.netdev
Subject: [PATCH nf] netfilter: ipset: fix extension leak during hash resize
Date: Sun, 22 Nov 2026 00:15:27 +0300
Organization: Usenet Network
Message-ID: <20261121212037.149722-1-omermetekaya0@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="3497001"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:ccBBjUJWyWj/sDIKsXK3zG5+/Ok= sha256:XoBLASDKElSHxLRyrzTt0z4wE8JQA6T9cl3H7M28z7I=
sha1:+kPYxXx7aMPnmLRAl7dP5R+KLR8= sha256:cvTVwqKSoPtPVXMqjf4PRG/W0jjWojR6v7ejI8+F4XM=
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 57909115BF1; Sun, 22 Nov 2026 00:24:40 +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 Uk4rMFz0uP4v;
Sun, 22 Nov 2026 00:24:35 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-368463-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 AB266115BEF; Sun, 22 Nov 2026 00:24:25 +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 38A6F39855; Sat, 21 Nov 2026 21:24:21 +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=1795296261;
b=fmcEw6hYxNieDIkAmowKqZ655hO6jpO5aY0NcyXEb+bDGjaGwaP7+yabBEPBhYCuG2Tg
Qk8gQnax2gCy+3griqWCcaRCuRYoSuv10BKI/XQz2cWnK9klJHeJHausRzWzaO7jOGTst
wx0qOsal9Qqd4jTa1MCtZvuQhSUL03odEEFdhzZwsgNZ0oGNnoJ+cZe+8MHUfQ7d5dRpZ
2tRWEq4GapbSTUeRR+TyZvYJspwFAQBWzLHzr5dpBtOU1i/nT9Fg5uwhDEK3D6Ac1tPs9
qS04ubWZ0iSXxd/pWXMoZRHFApvp82oE7f6ncOIY78aolsI297J80Qb9H4qSl037f7A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795296261;
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-Type:
Content-Transfer-Encoding;
bh=QnN9CxDyovVg8bGKbDx5lj1s9US1BmNCEq5WllIH360=;
b=0PzwVZCfZ2lE3TLI23jtEpo5x7/7Ko9GDZuDANCIcbE4oqOnvEiev3YM+LWQbMesg31U
faDf8Q9UfQt9yzTpT+sSXDmHWZUWtMv5W8wCqybgO5SXx/MlGN94eOqDp7R0l4BbVhuid
EW1QjlYUpu0UAjpKJHg8PutY2KbpBnSw3TrihRXVg/4Li94e/V6AKUGTwoEn6J5xKjPLk
QiKVy4NLRpKvFeDeImlWJddlZZL8asSmy9P3Sb1H3b+rC72KmeWFVuj2dKeDejPaS2eIE
hEJBBNFkXRoDmnJg0gkgxrJaT0rXBUxvuwK9PMh5sbE7b+VJpzE2TJUP0NDdc9K7Wrg==
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=YW2xYQ6p;
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 11905606A337;
Sat, 21 Nov 2026 21:24:21 +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=YW2xYQ6p
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.46
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1795296260;
b=0j1/EPVhViZPx0S96S9ByOeGdwaeWsUBpbPe+ZPhZ6XP0W8WEhNNhzCSXd9vYOiJtjpk
NgHO/Cvds0sx744o3hqlIzPOb2gXPHRNhixIoFMlpAeZlifn360RlCyzM0+YUGV0isGsB
n93KVEBqRLVuCuLcZnd2qjXo+dq+jexfGNTz3ApuLu3dThbYFCiUjwomeR0ZvFUf1waz2
e7tGAd/G85JII3BVzq2pABPc12lDATMNSTqVEh3vu2zGPRUJSPnqn0oBoPWz+P5tqOVy+
gCqQQNmhrktCIXqNmfE/KKCjcv/CW71mdNae/qCfzOgxqLK1wtVmPhFvuHs7WTZQvzw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795296260;
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-Type:
Content-Transfer-Encoding;
bh=QnN9CxDyovVg8bGKbDx5lj1s9US1BmNCEq5WllIH360=;
b=m1Z2HSy9nG1eP9Sc1b/w871/JhLaU9mMWnjHcOwN/ejVGPoKAB3RpjNBQu7XeTr5+1Eh
EPZK+HDswaiFkBhr7Oi60ql76MbD1CnSGgwqB+wQlqw/FNquy2X0gr2w6cLdrkwWPrECo
oLkKNfMTfbZTXG3tJTBMRwPWp1Y39KdJrM9FCI76mqvT3JDvMz1hp3NJuifrB8v3M84Sn
nVMTGcCxUojAYQJQMuXskv6qIcVVTi9JyUzwX13TXdetOeYG0D5UIG/eXYWT6NwYKFflI
vgCRBV/uhuy28bcjsB+3xjP/w0WReg7B/AMA7Y3NCsq+KlzQjTMPbb+mfZCZJJaTxFA==
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=YW2xYQ6p;
arc=none smtp.remote-ip=209.85.128.46
X-Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46])
(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 9A2D0606A32A
for <netdev@vger.kernel.org>; Sat, 21 Nov 2026 21:24:19 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9A2D0606A32A
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-wm1-f46.google.com with SMTP id 5b1f17b1804b1-4bb64ef5a14so21835095e9.1
for <netdev@vger.kernel.org>; Sat, 21 Nov 2026 13:24:19 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1795296258; x=1795901058; darn=vger.kernel.org;
h=content-transfer-encoding:content-type:mime-version:message-id:date
:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=QnN9CxDyovVg8bGKbDx5lj1s9US1BmNCEq5WllIH360=;
b=YW2xYQ6p5a+/qxuh6gQeHzVZ3q+n02Ssc0O6m0bU+KNH5dQ6q3GV5o3oloT+NNbWA5
u9OZgm54775PMXQDC8bpf/J8uQDss7hnYA+QUxDR0JGdmoilqw5laNHTEN2N6UhpV7ge
Q/AG/VmHISqJFZm4JTQ0lmpnoQdpyXk2hp/nbQ8TyXol1P2k+U6CQZlqi2UlcNjUpHCD
nHpFKkki+pVOJvNQtcB9sTywJQNK9UcaoIC1wKqVZkrqk8oHvqVbI0Hf7hz1bGYrWVpn
kFQ+yhL2+RrO+AtSSHWxjyjRRDmbAUlzNN+bdxdp9tjiG1IjtWTYsyo7IPLGVZEiHF3S
q1Cw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1795296258; x=1795901058;
h=content-transfer-encoding:content-type: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=QnN9CxDyovVg8bGKbDx5lj1s9US1BmNCEq5WllIH360=;
b=tLXsXtJ5GDf+cSjgPnCzP5IF7jWswTvaCR0Fv2v1KLGT1fsMkb1AwJs0hc/PvT5J4E
jLMQ6YdfHOYznPOvH+hDJxC2QBPd9itK6T/DgtWT6ZIjDJWcxEveveErFXl+pyuEziuD
mTIEY2cJ4ZdrPAFaEwzGpezkpDbb9BWl/ASUHh4VKN27AyiGbHPeVovB9SVelkZaBnjV
MVdotMPHNQJ8c4aTD/IwlNgyY10HH4Dm92arn8WGKRaDA92mp+dEHzmiFMbfAFVN15J2
J7YHse/4efL+Ytzj0k7hS1/iUzrGhRPrLqgqxXqKrIJNB49t4Ce01wKH5ISKthSBBeJS
7RtQ==
X-Forwarded-Encrypted: i=1; AL+hErGKk2+Jz9Nj8/OppdNnrrm4cHSY44PF/KYZ7XBG+lYYQ5rLA50RQes+Cmf70pXwOKYSdE2tXZo=@vger.kernel.org
X-Gm-Message-State: APuU4Z9NahD+b4dsfE9R0PwPV/oGIYShgMDi0e65dHDrLLFdPk48N9Cw
zySprbbBJqkvcT1eqesTiI6TCtlrdvp2vYPTgRmlCHs02TOI+Ut56MAS
X-Gm-Gg: AZFdTZf7aPspD6H038sN6YjfNLe8aXie5rDgrNb2Xahx+GZ6XPGISmDru3vjwymwcBV
ESQM2Suxw8K/wgtyZg/yUUnZUlpM6K/eucRk6ZMGyhoagpGC+ileQYQkqxjkjYW2FlpnpkZTBSH
7/e7bIxwQrE31F6TE8nN1bgm3H9smIV7VdODFLv2JirrRw5lo2vSVlwbd11B6T3wUBhocPOP2g+
r4gMgPbYNKvj9qVXKrbhnxM1v1aqp9qcgd9IBooF1p0xamu1eFwBkBCk1VJERoOArE9QZmHY0fG
ly42gjoFg/giwTYlbNf7ApcWNDvAIyIdq9NXBZo51G8ePA3fvbN65hxhT09OFAv07c79jFwMtkE
RbfBtyiB0QWwOa7Jxv2qrT2ayUgo9enjXkIVExx3mZWeBz891fVIglqWI2hwkk8VHrpS/taaogh
An4R2EGotrW4ExRXrVgkXG0oteHeS9eWMJ27QKXZWCvFLF8yeboDK69UprLoJs3GNjrttjE0X1D
hfR/COKQElkEdE15/h87M9wpq3ETv/UNKLRdzVfEHXfITn9PQPWlLIpifWoDa2Bym3fDW5cLr/o
g2FP084cbdDouQnwemE4rqfwsQ==
X-Received: by 2002:a05:600c:4f15:b0:4bb:6861:657d with SMTP id 5b1f17b1804b1-4bb88923954mr173957455e9.21.1795296257761;
Sat, 21 Nov 2026 13:24:17 -0800 (PST)
X-Received: from metepc ([46.197.185.3])
by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb905f1489sm79231845e9.0.2026.11.21.13.24.16
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Sat, 21 Nov 2026 13:24:17 -0800 (PST)
X-Cc: phil@nwl.cc,
davem@davemloft.net,
edumazet@google.com,
kuba@kernel.org,
pabeni@redhat.com,
horms@kernel.org,
kadlec@netfilter.org,
netfilter-devel@vger.kernel.org,
coreteam@netfilter.org,
netdev@vger.kernel.org,
Ömer Mete Kaya <omermetekaya0@gmail.com>
X-Mailer: git-send-email 2.56.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