Article View: linux.kernel.netdev
Article #7463Re: [PATCH net v4 2/3] netconsole: read np.dev under target_list_lock in local_mac_show()
From: Breno Leitao
Date: Mon, 26 Oct 2026 11:52
Date: Mon, 26 Oct 2026 11:52
52 lines
10620 bytes
10620 bytes
On Wed, Oct 21, 2026 at 03:19:06PM +0100, Gustavo Luiz Duarte wrote:
> local_mac_show() loads nt->np.dev and dereferences it with no lock. It
> can race with the interface going away and netconsole_netdev_event()
> eventually calling netdev_put() and freeing the device before we
> dereference it, leading to a UAF.
>
> The window is only a few instructions wide, so I could only reproduce it
> with an artificially widened window between the load and the
> dereference:
>
> BUG: KASAN: slab-use-after-free in local_mac_show+0x4e/0x80
> Read of size 8 at addr ffff88800e990458 by task uaf/130
> local_mac_show+0x4e/0x80
> configfs_read_iter+0x187/0x260
> vfs_read+0x453/0x5a0
>
> Allocated by task 116:
> alloc_netdev_mqs+0x78/0x830
> rtnl_create_link+0x53b/0x5c0
>
> Freed by task 121:
> kfree+0x159/0x420
> device_release+0x77/0x120
> kobject_put+0xb5/0x160
> netdev_run_todo+0x420/0x850
> rtnl_dellink+0x259/0x5b0
>
> Two places can free np.dev: (1) netconsole_netdev_event() moves a target
> out of STATE_ENABLED under target_list_lock before netdev_put(), and (2)
> process_resume_target() releases np.dev under dynamic_netconsole_mutex.
>
> Fixes: 0953864160bd ("[NETPOLL]: no need to store local_mac")
> Signed-off-by: Gustavo Luiz Duarte <gustavold@gmail.com>
Reviewed-by: Breno Leitao <leitao@debian.org>
> @@ -888,10 +888,23 @@ static ssize_t remote_ip_show(struct config_item *item, char *buf)
>
> static ssize_t local_mac_show(struct config_item *item, char *buf)
> {
> - struct net_device *dev = to_target(item)->np.dev;
> - static const u8 bcast[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
> + struct netconsole_target *nt = to_target(item);
> + unsigned long flags;
> + u8 mac[ETH_ALEN];
> +
> + eth_broadcast_addr(mac);
Yeah, this is much nicer than the bcast one. My only concern is that
this is a fix, and it changes quite a few things beyond the fix itself,
which will make backporting it to stable harder.
Technical Details
Message-ID:
<at8-E_EP8B3x6BFi@gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351871-linux-kernel-netdev=dewy.ruReferences:
<20261021-netcons-fixes-v4-0-3857120c6340@gmail.com> <20261021-netcons-fixes-v4-2-3857120c6340@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-351871-linux-kernel-netdev=dewy.ru From: leitao@debian.org (Breno Leitao) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v4 2/3] netconsole: read np.dev under target_list_lock in local_mac_show() Date: Mon, 26 Oct 2026 04:52:48 -0700 Organization: Usenet Network Message-ID: <at8-E_EP8B3x6BFi@gmail.com> References: <20261021-netcons-fixes-v4-0-3857120c6340@gmail.com> <20261021-netcons-fixes-v4-2-3857120c6340@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="1298561"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:20pLAXosgRzjMP5ZcRHfxHMpPBw= sha256:+2kd2v/4TpwKQO1ucWTCuAjnWd536vMmC1wSaAHBbZk= sha1:LCSlwJ1MkTJKcP1UUoeLhu2LAeA= sha256:nlXJ/pjPxaKTTAkUMNFtaQeN4XrBb39O5vgAWGv1mPc= 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 0E06D125B9E; Mon, 26 Oct 2026 14:55:55 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.489 X-Spam-Status: No, score=-3.489 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.339, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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=debian.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 Jd-XRGLjHhs8; Mon, 26 Oct 2026 14:55:51 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-351871-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=debian.org X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id AA71A125B9D; Mon, 26 Oct 2026 14:55:43 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 978BD602F4D; Mon, 26 Oct 2026 11:53:15 +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=1793015590; b=z/6hPM8UGfR/3dO/AQDwRICyRxq8NbyFCbS+ZnFmwdM9jNZpJG35Z77y6CEaw3wf2ioy 8VEhlqp3Yk+rGJzkj75st7wSX0D3ScO+EUoPdywCkCDVsbaK6Yvv1WKpPx0HrHgGrATQb Hn2lwpOYZy1bdUSZtQHgXFSVjAEaet0QRu4kNiCHkv1wMT4YbAJHdjyXMwMGcbcV8yE2X IGlx/nNHB+6NGCf2QL9AleUT98+oMJKnq59m3lIW1A82T2nNPvK7Cg/FbpNxbi65O7yQz DGnVIVJU91ZpWOS/e1/Wa6pOPyoH3/GJZRx+ATxhyzWApp72EASkDyqHykyyS7gk+uQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793015590; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received: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: X-Debian-User; bh=muRBYzWWqUsiTqMXGBh1F+ip6DW5FQ1L0G5hI7qvkU4=; b=2jVIVYbvT4V/qqBhKdP31w1C/9eAC87u3i+EORsoXZ0MneKk0KepkHlhHloWNXcMnaa3 21wBQ5scTG32/ui0kfg2qQX8TyOiOsVqm3p0NyXwwCdYyPR3AhwgwJ71MynZJm74O/4I6 rgJZo/jY/K5g8CE1yevTJZNUFhdPCdI2hNCbVdUOL7wwHS0cKPDdFyNt4a4LHykHM/LEl fMUtuTua0wUjx4kFebhonVjTJGBj+eMetFrAlg2bbXbYHgXfnzXWdYez4BxVUV9e+OlzY PW97V8xnisUWqwg+J9MrEpcHmN0j8exxCPEeo2LzkUtiiDsj6jH6UVHtdZjLhkG0Q8A== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=debian.org header.i=@debian.org header.a=rsa-sha256 header.s=smtpauto.stravinsky header.b="vj/FpkW1"; dmarc=pass header.from=debian.org; spf=pass smtp.mailfrom=debian.org; 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 68FA3606A32E; Mon, 26 Oct 2026 11:53:10 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=debian.org header.i=@debian.org header.a=rsa-sha256 header.s=smtpauto.stravinsky header.b=vj/FpkW1 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=82.195.75.108 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793015579; b=oBLv9hE79VlO+0pRAwTJ2ZL8RcQDjGmn/kEHjDmp0rf7OT7j5c4EWuo/Et6hR61oT2tJ EXBi5m7ASWYqW+7n7/tzng/4wicJulalzbXRS4WlgL0WWBIzcH3XBhz8hZEtDgILrKFFp 7pff065DP29o2NMs/HHVB8LysjxdM5k/0fqkM0LlwX45XZKz9O1ch3QJEQPnT57/Bg9TV 0/FqNTjrV/ZxrDn80QRXVLiVABl1LNWxiu93lL9feZRUFCoaHqFIP8vm5TXGab6bGLpr+ qDlZP9K6P5M0jLgWwFufLnqpGuFDj6R+TtjfcDh43u8kWeZBwqo77r3ZWlJpXAZqakQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793015579; h=DMARC-Filter:DKIM-Signature:Received:Date:From:To:Cc:Subject: Message-ID:References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To:X-Debian-User; bh=muRBYzWWqUsiTqMXGBh1F+ip6DW5FQ1L0G5hI7qvkU4=; b=BMyoxIE1TiVIjM8Crx4nSYOczFMAV2iGVw+r38cqqnpgg0S2uyR/DPmuK8W/9dNfLjQ/ NVYWP1X7nDzF0P9iH6YqxbxidOopg3CD/Qt08wlJT3O+YGwc6YhG6EXouvS7PFfVjgr0x G46sL9WORknfJnv7FWrUU6b57dwTb/0+1FwtajcKcSr1eI8XM0VZt3TpTfn7ozK+Ngfuf Db0VLiKR32DEs/Hk9aF4/PeixqAdXBJbZ5Wu/vHIbbBgOkUD74LruMFYxiSgv702YcdNF 9ne5ArTbucy46EUuBzaMFhtkUR4qNFa723eVIJ+qTVqVuOke3qI1YpPcRfi84QMdbSw== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass header.d=debian.org header.i=@debian.org header.a=rsa-sha256 header.s=smtpauto.stravinsky header.b="vj/FpkW1"; arc=none smtp.remote-ip=82.195.75.108 X-Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E4396606A31B; Mon, 26 Oct 2026 11:52:58 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E4396606A31B X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org X-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=muRBYzWWqUsiTqMXGBh1F+ip6DW5FQ1L0G5hI7qvkU4=; b=vj/FpkW1ZOQmSYvYZLBvez8zkK wzkdQ3yZs32dv+fHFQBTaautS364nQ0U1Jj9dsvorR9vH2HBd7uEbESCzHBdwFoBJPJkVHJH/vlrg rE5NgklBGoG77Uxyv26qtMuGw2k99CdxaQ94uUmSqAPL/Pe0QkKjCACjs8yYlrhEUMF/1LTc8oxyE RDkVesG9Ets6BZnyu0nwm7SluaetDGsilC1Tpz9I1QliMFAdr7edKyKmxH32GSWk419yEj1biaG+k fe4Z08+pG49TY72+avc+RU8T+Xb+rN/BIYB6emWxwquC01AkEd9cZGpTGHeQVsPU4zCaBiMduSAfc WPEbfvdQ==; X-Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from <leitao@debian.org>) id 1xLJG0-000en3-38; Mon, 26 Oct 2026 11:52:53 +0000 X-Cc: Andrew Lunn <andrew+netdev@lunn.ch>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Stephen Hemminger <stephen@networkplumber.org>, netdev@vger.kernel.org, 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: <20261021-netcons-fixes-v4-2-3857120c6340@gmail.com> X-Debian-User: leitao