Article View: linux.kernel.netdev
Article #23428[PATCH net] netlabel: fix a race in netlbl_unlhsh_condremove_iface()
From: Linkui Xiao
Date: Fri, 27 Nov 2026 09:23
Date: Fri, 27 Nov 2026 09:23
46 lines
10495 bytes
10495 bytes
From: Linkui Xiao <xiaolinkui@kylinos.cn>
netlbl_unlhsh_condremove_iface() unlinks an interface entry and queues it
for freeing without checking ->valid, so it can do both a second time for
an entry that somebody else has already removed.
netlbl_unlhsh_remove() looks the entry up under RCU, drops the lock,
removes the address entry and only then calls condremove_iface(). If a
NETDEV_DOWN notifier runs in between it takes netlbl_unlhsh_lock, clears
->valid and does list_del_rcu() plus call_rcu() on the same entry, and
nothing serialises the notifier against a STATICREMOVE doit, which only
holds genl_lock. The second list_del_rcu() then dereferences the
LIST_POISON2 that the first one left in ->prev, and the second call_rcu()
queues an rcu_head that is already queued, so the entry is freed twice.
The default entry can hit the same thing without any notifier: smackfs
reaches netlbl_unlhsh_remove() through netlbl_cfg_unlbl_static_del() and
is not serialised against a concurrent STATICREMOVEDEF, so two callers can
each remove one address from the same entry and both find it empty.
Check ->valid before unlinking, the way netlbl_unlhsh_netdev_handler() and
netlbl_domhsh_remove_entry() already do. Everything that invalidates an
entry does so under netlbl_unlhsh_lock, so the check is reliable.
Fixes: 8cc44579d1bd ("NetLabel: Introduce static network labels for unlabeled connections")
Signed-off-by: Linkui Xiao <xiaolinkui@kylinos.cn>
---
net/netlabel/netlabel_unlabeled.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/netlabel/netlabel_unlabeled.c b/net/netlabel/netlabel_unlabeled.c
index 47bae5e48db6..d73c27b0c9d0 100644
--- a/net/netlabel/netlabel_unlabeled.c
+++ b/net/netlabel/netlabel_unlabeled.c
@@ -582,6 +582,8 @@ static void netlbl_unlhsh_condremove_iface(struct netlbl_unlhsh_iface *iface)
#endif /* IPv6 */
spin_lock(&netlbl_unlhsh_lock);
+ if (!iface->valid)
+ goto unlhsh_condremove_failure;
netlbl_af4list_foreach_rcu(iter4, &iface->addr4_list)
goto unlhsh_condremove_failure;
#if IS_ENABLED(CONFIG_IPV6)
--
2.25.1
Technical Details
Message-ID:
<20261127092325.3563681-1-xiaolinkui@126.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372570-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372570-linux-kernel-netdev=dewy.ru From: xiaolinkui@126.com (Linkui Xiao) Newsgroups: linux.kernel.netdev Subject: [PATCH net] netlabel: fix a race in netlbl_unlhsh_condremove_iface() Date: Fri, 27 Nov 2026 17:23:24 +0800 Organization: Usenet Network Message-ID: <20261127092325.3563681-1-xiaolinkui@126.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="693806"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:wKQH3XgECiJxerQGyo/lrv3EW9A= sha256:UXQrSDI+q1KhfO8WLM1euHh4HJJ7V+sNYl0GeWzoYZI= sha1:99SZFfZmNOYC4my08t/fKKN2OYM= sha256:TYNqiNu4IJw8B9IjEv3rSdASdy5ImqTmPcypr0bd8Q4= 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 1610F125F39; Fri, 27 Nov 2026 12:24:43 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.048 X-Spam-Status: No, score=-3.048 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, UNPARSEABLE_RELAY=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=126.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 goL4mOatWzXS; Fri, 27 Nov 2026 12:24:40 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-372570-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=126.com X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id 577A2125F36; Fri, 27 Nov 2026 12:24:31 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id E673E27CA8; Fri, 27 Nov 2026 09:24:28 +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=1795771465; b=gDbkbOkCsV6KbtUhZIg27cTIYrFCi3BHSt0EXbLrAq0fQFxdAaceg2kFUcsurN6tO5J9 53DMD1zM+eKQ2bzLsq1Dinb5YJTgpJOdsC2K8pn0SRQjA3qRJnB5K6obHeUHulvmesy+/ 8+pW0UWlG9NSM8NsfaX92KsWdG3ShgzssAiUkXmqnyzucSIoHVe4Ed/EUYgeRbVBESDJb pJ2Glsq5V79jAQoxsQCSRHSLN4w7AkbJxBXB9OaFUtP/BobtjK2J27Cmls4l34KqrMt3H ttiXFBk9qAZFBAi+7iCkOK87HxHgRngYMbsGgbTLg9Uq0JIY4/k6mVVJCwuZk1sPm6w== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795771465; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature: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:X-CM-TRANSID: X-Coremail-Antispam:X-CM-SenderInfo; bh=7ty1iZfjrQRaq0ygLizQ45rXD2THgByLVqAbfFxEQJg=; b=KWGVwlvSsLVM7JRJCOt7jQCh1+oVRRjVObnfUZxrFk529k79q2EEl8Zdj5yxNslEucfv HF+kW2cBuUaRU0AcPmUZ4oZJZIBNMnvvGJ8ULplCGLbXh9otagve8VXZbETKv5lakq+cN fKRYMK+j+OgQkX/TWcoPw9aAScO++K5AYvdIgENiTb1n8BiE4/A5AO03YGy2Y9PORPabI pPfdyutDgUMmaRR2+g9afkvg95bZ3gLjE001a9gi6eyovpPFdispFaJZH61pNjXGznkJJ l0w12kfO7+TcSY4LAXE37Y4QGALhskUEAEOg3oXO9KN1J5xs5/nl7/Havk2eFVO2nYg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b="IE/YnoAq"; dmarc=pass header.from=126.com; spf=pass smtp.mailfrom=126.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 0B138606A33A; Fri, 27 Nov 2026 09:24:25 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=IE/YnoAq X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=117.135.210.7 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795771459; b=R1CKzt/G61e0hsfIrr9trhFP716eWxJ+W5kLyGsm4HA88mpURWQhxtPFSUeqdVfnPJpe z0j7VuYVYiErPOXQTyild1j+5kmW0il/psVw9sEBFJ4iGZtxiwFGAAref2ZDmJeh7tBoi Zx1RRHaRH6Dv+wVEOOPJYE+TXqsDFLl/6rMo9oG4M4go6fIMd4k3RaWV0kCGQD7dovn+S 6bEpbk7y3ql12inwcTgyX2FxZ1SDoI+nrPak8x4s3sGfEK49qwh+7/ORaticjfhq7Ka/1 cO3TEOF9eCc5mSj3+kjhQJRnSpSLO9KKUJ3KVGLvHuaStmMQWsCbskcYSi3v+jazLpQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795771459; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-Id:X-Mailer:MIME-Version:Content-Transfer-Encoding: X-CM-TRANSID:X-Coremail-Antispam:X-CM-SenderInfo; bh=7ty1iZfjrQRaq0ygLizQ45rXD2THgByLVqAbfFxEQJg=; b=ZN02c6pOaYNDRUYDD7M5qVNvY2qvy4l/KCcnGjHa1I8n+ZIGSfLon9JSSIiNXZI984GA fhA3kxie2ji9eREiZUXvQK/JqChaqkzFnvHE+dvXKwlQ3ANWPSYkxeQEo4PmF/uMJIckQ th847GRTOd1J+CmBPQgk4J/rhg7GlPnOORuzDBxUa0bCQbGkyO/IIUxlDaQnZHnyJg7eY SPHeZ0tfyEsAOGHVOnUuw0pgG3hywea/DR62JOXBVxIVcXoWtS7gdo9boLqRofuerYGT3 NKerau6hdojVoBULiwPku4B0eH/vsdjyZFXwxTF4RSbxOQbVmQ4OLLmET5zfPIVgjqQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=126.com; spf=pass smtp.mailfrom=126.com; dkim=pass header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b="IE/YnoAq"; arc=none smtp.remote-ip=117.135.210.7 X-Received: from m16.mail.126.com (m16.mail.126.com [117.135.210.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0366C606A32E; Fri, 27 Nov 2026 09:24:15 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0366C606A32E X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=126.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=126.com X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=7t y1iZfjrQRaq0ygLizQ45rXD2THgByLVqAbfFxEQJg=; b=IE/YnoAqLf4H1iGFua kEGA15gVI4wuOCjx1ToGPtkbsqq2ojIZVMqFC5SWuk6/sEbMYqK9HMYDm+hCpg3z crB8SyT01X5F+Bgnc4BDCcjYIeo1qOBVMMAEdzj2ziyjJyXzA+AqMeGY3cOgX5tA wuhvNmcY6MuhvMYQwXgq38jR0= X-Received: from localhost.localdomain (unknown []) by gzga-smtp-mtada-g0-4 (Coremail) with SMTP id _____wD3NzAPTAlrktpmEA--.64683S2; Fri, 27 Nov 2026 17:23:27 +0800 (CST) X-Cc: "David S . Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>, James Morris <jmorris@namei.org>, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Linkui Xiao <xiaolinkui@kylinos.cn> X-Mailer: git-send-email 2.25.1 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 X-CM-TRANSID: _____wD3NzAPTAlrktpmEA--.64683S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7KF1kWw1kXF45KF4xXryrJFb_yoW8tr1kpr y2qrnYkrykX3sIqa92vF4UGrW0va1UCFWUCr1Sk34FyFs8Xr13ZFyUGa9rZa45ZFs7JFZ8 JFWUXws8Ww48WFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07ULFxUUUUUU= X-CM-SenderInfo: p0ld0z5lqn3xa6rslhhfrp/xtbBqQ8zCmsJTA8GYwAA3b