Article View: linux.kernel.netdev
Article #12078Re: [PATCH net] netlink: Do not call the unbind callback with the table locked
From: Simon Horman
Date: Fri, 06 Nov 2026 08:30
Date: Fri, 06 Nov 2026 08:30
26 lines
8910 bytes
8910 bytes
On Mon, Nov 02, 2026 at 12:09:29PM +0000, Anil Kaushik wrote:
> When netlink_bind() fails to insert the socket, it calls
> netlink_undo_bind() with the table locked. genl_unbind() then takes
> cb_lock, while genl_unregister_family() and genl_register_family() take
> cb_lock for writing and then wait in netlink_table_grab() for the table
> users to go away:
>
> netlink_bind() genl_unregister_family()
> netlink_lock_table() down_write(&cb_lock)
> netlink_insert() fails
> netlink_undo_bind() netlink_table_grab()
> genl_unbind() waits for nl_table_users == 0
> down_read(&cb_lock)
>
> An unprivileged user can get here by binding to a port ID that is in
> use, with nl_groups set. Lockdep does not see it, as nl_table_users is a
> plain counter.
>
> Unlock the table first, as the comment in netlink_release() asks for.
>
> Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261101101347.3910654-1-anilkaushikwireless@gmail.com
> Fixes: 3de21a8990d3 ("genetlink: Add per family bind/unbind callbacks")
> Signed-off-by: Anil Kaushik <anilkaushikwireless@gmail.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Technical Details
Message-ID:
<20261106083029.GB865646@horms.kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-357841-linux-kernel-netdev=dewy.ruReferences:
<20261102120929.4077030-1-anilkaushikwireless@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-357841-linux-kernel-netdev=dewy.ru From: horms@kernel.org (Simon Horman) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] netlink: Do not call the unbind callback with the table locked Date: Fri, 6 Nov 2026 08:30:29 +0000 Organization: Usenet Network Message-ID: <20261106083029.GB865646@horms.kernel.org> References: <20261102120929.4077030-1-anilkaushikwireless@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="3828474"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:6acfDcbrMXY8i3o+E2AmrHueuw4= sha256:yMAdVI0syGD11DCb7uay22+7fmMMXhU5yI9hTRh0GdQ= sha1:yHlfVp8oLWG/KSmVa1hW6SHSzqE= sha256:s2/v3+Vuf0LNZhZFcWLn0Y5UPKh+Ak2dMaJ8KqNV9s4= Content-Disposition: inline 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 2C5621131B7; Fri, 6 Nov 2026 11:33:12 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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=kernel.org 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 9Sv0vk46AjeJ; Fri, 6 Nov 2026 11:33:06 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-357841-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id F316E11319B; Fri, 6 Nov 2026 11:32:57 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id A3E7F2606C; Fri, 6 Nov 2026 08:30:37 +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=1793953834; b=steRDRymOq/hcx7gUUGzreQGcd38Qwey6Rn0scs+ZigzMHpCB7ojWOR6pCb7Zp/T5k37 g0nuybK8Lw5B2asKGhjYAkdzZH3jTMQghpkaLR93hciTnvi/W94LOFN82PIlw28yHPbSP /Rg1pKMBygBCim7eWs4NlGM1dVk4v1m40fUhP1JF1lMHMi1kzh85/WlPMzTVNKlKhe9Cx 3Ghz7OV6CaUX6t472pzGqXmtyJDPQmaJr57Y+gJuirHMHYJb0v4CkuYXs7kjLWTxFb8rW pmKuJNuk9a937PKWGdcoEMtFUuKY1so8mokG3dBORdSmxweeQHp5SCB+FaRauvbsVAw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793953834; h=X-Original-To:Received:Received:DKIM-Signature:Date:From:To:Cc: Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=3N258oZT74mhgatkaTIaW62KzUyIR4jJZkFJiLgrRQ8=; b=IxASDJxntAt3EFX452RNowVnQZ7XAeB3MkDlWDyarfUVX4yk0mnwStd1z3R33PkPzZf9 yygxuC+7Vnxvw4lpXfAvafD+dBrk56Try3z2qc2QZgmkEHj+r9Y+zeGBSs9FKTwjMRGuw x8GlcGv4Bv1PwAaySGtsQVx+z0XnNNQNXC0YeiDlp12kPw9/Mg6K91cK69seCMZGFtv/3 bhZGLtyyNkU9kne1jNz1wZgEzA5m7JU0zA5uFNAoRRGohMx+Pjn/dWt9/gn3uj1/V7a/q 6/uWi7g9WhxFj1N5/kSPsaHqLEcx89ruccLoY8tq+oYyxmdIx3XcyWS11BK7bR6Ssmg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=B03nwNLN; 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 9C428606A328; Fri, 6 Nov 2026 08:30:34 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=B03nwNLN X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793953833; b=rYEhIhEKTsqN4Icgbe65Sf53j4RUhiQ8tHXaNZyZ1FZ8GJRji9pN+ef66/NPu1f/i6kz 4y1f0c3yGn773rp+MNIaUs91EJj/DlGN/rSkMiuB3n+Klcpv/mqS/T4snLj75+I3+CyLM 5PYxCDq3mUGMa91OgHStLKGioeo4HVh22CebZhP4MDWXIH7sK7Wo27q867m9YZB3494Ft xXf2zcj0oUd0bPL6AEEdWaEqieuRIYUtCGY//pOKALhk0tCfyS0PVIhJTdOccE1za9bhP BjGDViZoZk055KAASH6zNaEzFmjeaaXNgaaHE5jx4z2TRLo9r4cyCBhJ2L/tt7PzVLA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793953833; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=3N258oZT74mhgatkaTIaW62KzUyIR4jJZkFJiLgrRQ8=; b=BQxvVGeRaZHXXL3QciV72R1xEvcjQbAUj4R2HdSKHU9tR1DNzac/PWJMUj+xS8fPZGIP i/I7T1W129mjcV8l712lkcYfn96YvqmAhvdDe+ik+XIaDm3/n214U4zkSHEnhllS1J6KW HugDFi7B2K0ygZcYQ4C4V/gB1gs3TiH9x85osZLhwSEGHFII5HIpMslZQIVIQSLdtkdN2 7gVDv+rNmsuoaS+K1I+qWAztOvj76Thcic9SFX9O6oQqcHzxmfaDOm5jm2lpOZzPfGSUH 9yg2W493I+xm+xmldyL2BIigvEkmqqCgiyLnzBNGa4VgjvQQxRb9B8IM6+ggBIZ0pDw== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=B03nwNLN; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 79563606A32C; Fri, 6 Nov 2026 08:30:33 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 812861F008A1; Fri, 6 Nov 2026 08:30:31 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793953833; bh=3N258oZT74mhgatkaTIaW62KzUyIR4jJZkFJiLgrRQ8=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=B03nwNLN5bke7U/Cj5BvvV/NfbR+FoJjEaEvKHFnD+7Q1JVY58BDgDIJV6LULSI1p mOSShNtQD6mr7FW0ilC7iF1YNf+F3LL1roadBLoFhM5BuH5/p2AeW11ykuPYyhC6hM FA2Vtfj6qr3Ux6qhGR/BHBPnh7dJfYlASQYRtXMumXVTNFq7UWvFPgTbjKsJlFo4wo ny9U5eeQow601rqYDib9TRrnB7dHL4mxbtMsJTz5wFJfpoYsGiGxdZleDFYKqJofOK csKld4Nu2QkgHQpHeanzP3eVcFffeBRzOCEvsydRPYAYI+aQTZscUVU7z+F9z1tzkP tVP2il7Zh15qw== X-Cc: netdev@vger.kernel.org, "David S . Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Nicolas Dichtel <nicolas.dichtel@6wind.com>, linux-kernel@vger.kernel.org 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-In-Reply-To: <20261102120929.4077030-1-anilkaushikwireless@gmail.com>