Received: from smtp-out.kfki.hu (smtp-out.kfki.hu [148.6.0.49]) (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 2D664351C06 for ; Fri, 8 May 2026 21:04:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.6.0.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778274260; cv=none; b=NAJeDYGlp1SnFjQ4aJe/8izimDBxeuigO/CewqyRt4pXFP85esukR3kWCowG/XUlqccmaVDM90TZZBDHs2GNVsuPzsLor+KrU7gAUPfhFIm5BTd10B1RP7QyYWNTnVbet4i4tvClh80xDiXIdes5Gyg2r2jCUXkI6KG3FZG1n2M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778274260; c=relaxed/simple; bh=XICrzaBAIxlR9y5HBepOoF2WZD+0n3LpVE484qnsp3s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=vCnagc/1ZxUKk4SuxQyfWok6aqN6k2QUNiidXzx9EHqAS4l2qAvJLdqI+m5ylxoXmnKBbkDd67wG19QxhEpj8rcy31JmyVaKrW+bwUJmCEKGUus4C2KcAD/QObni8ta6Ik5ujnXqLM1kqZL2Es19Sq5z52eeSpeC0yGuRkavBGc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org; spf=pass smtp.mailfrom=blackhole.kfki.hu; dkim=pass (1024-bit key) header.d=blackhole.kfki.hu header.i=@blackhole.kfki.hu header.b=SXER3OsO; arc=none smtp.client-ip=148.6.0.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=blackhole.kfki.hu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=blackhole.kfki.hu header.i=@blackhole.kfki.hu header.b="SXER3OsO" Received: from localhost (localhost [127.0.0.1]) by smtp0.kfki.hu (Postfix) with ESMTP id 4gC1gt4xYLz3sb8s; Fri, 8 May 2026 22:59:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= blackhole.kfki.hu; h=mime-version:references:in-reply-to :x-mailer:message-id:date:date:from:from:received:received :received; s=20151130; t=1778273944; x=1780088345; bh=RW2lQhxLAt V/0hfjWi32b0FOQWEQYFGEgsJmW1yFSnM=; b=SXER3OsO625aTa6cU2SEyPbRyP hl1F3xbec44x+UaCDbxh42nplmFxUMCzyRThMn+3c63MRcPhnvuesw/eYm/t7Jzv DohgoJkXz7zsztPHjoetJf2wmz9qYB4NqOSFXauhDsYcplCS4t95HC6ScXNYkaJY 43s6uzQuh+GoSVf0I= X-Virus-Scanned: Debian amavis at smtp0.kfki.hu Received: from smtp0.kfki.hu ([127.0.0.1]) by localhost (smtp0.kfki.hu [127.0.0.1]) (amavis, port 10026) with ESMTP id Un9YCcrjOTKo; Fri, 8 May 2026 22:59:04 +0200 (CEST) Received: from mentat.rmki.kfki.hu (254C131D.nat.pool.telekom.hu [37.76.19.29]) (Authenticated sender: kadlecsik.jozsef@wigner.hu) by smtp0.kfki.hu (Postfix) with ESMTPSA id 4gC1gr4zCkz3sb8r; Fri, 8 May 2026 22:59:04 +0200 (CEST) Received: by mentat.rmki.kfki.hu (Postfix, from userid 1000) id EBA3F141D33; Fri, 8 May 2026 22:59:03 +0200 (CEST) From: Jozsef Kadlecsik To: netfilter-devel@vger.kernel.org Cc: Pablo Neira Ayuso Subject: [PATCH v6 2/8] netfilter: ipset: Fix data race between add and list header in all hash types Date: Fri, 8 May 2026 22:58:57 +0200 Message-Id: <20260508205903.10238-3-kadlec@netfilter.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260508205903.10238-1-kadlec@netfilter.org> References: <20260508205903.10238-1-kadlec@netfilter.org> Precedence: bulk X-Mailing-List: netfilter-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-deepspam: ham 1% Content-Transfer-Encoding: quoted-printable The "ipset list -terse" command is actually a dump operation which may run parallel with "ipset add" commands, which can trigger an internal resizing of the hash type of sets just being dumped. However, dumping just the header part of the set was not protected against underlying resizing. Fix it by protecting the header dumping part as well. Signed-off-by: Jozsef Kadlecsik --- net/netfilter/ipset/ip_set_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_s= et_core.c index 0874029cb0f2..3706b4a85a0f 100644 --- a/net/netfilter/ipset/ip_set_core.c +++ b/net/netfilter/ipset/ip_set_core.c @@ -1649,13 +1649,13 @@ ip_set_dump_do(struct sk_buff *skb, struct netlin= k_callback *cb) if (cb->args[IPSET_CB_PROTO] > IPSET_PROTOCOL_MIN && nla_put_net16(skb, IPSET_ATTR_INDEX, htons(index))) goto nla_put_failure; + if (set->variant->uref) + set->variant->uref(set, cb, true); ret =3D set->variant->head(set, skb); if (ret < 0) goto release_refcount; if (dump_flags & IPSET_FLAG_LIST_HEADER) goto next_set; - if (set->variant->uref) - set->variant->uref(set, cb, true); fallthrough; default: ret =3D set->variant->list(set, skb, cb); --=20 2.39.5