🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #124

Re: [PATCH net v2 2/2] netconsole: read np.dev under the RTNL in local_mac_show()

#124
From: Breno Leitao
Date: Wed, 07 Oct 2026 08:58
32 lines
7214 bytes
Hello Gustavo,

On Tue, Oct 06, 2026 at 07:21:26PM +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.

Thanks for the fix.

> --- a/drivers/net/netconsole.c
> +++ b/drivers/net/netconsole.c
> @@ -888,10 +888,17 @@ 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);
> +	int ret;
>  
> -	return sysfs_emit(buf, "%pM\n", dev ? dev->dev_addr : bcast);
> +	/* Hold RTNL here so netconsole_netdev_event() doesn't tear down np.dev
> +	 * from under us.
> +	 */
> +	rtnl_lock();

Same idea as Eric suggested earlier, this might be doable without having
the heavy RTNL, but using netconsole's locks

--breno
Technical Details
Message-ID: <asYJRc4mU1qUrdgQ@gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-342273-linux-kernel-netdev=dewy.ru
References: <20261006-netcons-fixes-v2-0-ca652d55fd4a@gmail.com> <20261006-netcons-fixes-v2-2-ca652d55fd4a@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-342273-linux-kernel-netdev=dewy.ru
From: leitao@debian.org (Breno Leitao)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2 2/2] netconsole: read np.dev under the RTNL in
 local_mac_show()
Date: Wed, 7 Oct 2026 01:58:20 -0700
Organization: Usenet Network
Message-ID: <asYJRc4mU1qUrdgQ@gmail.com>
References: <20261006-netcons-fixes-v2-0-ca652d55fd4a@gmail.com>
 <20261006-netcons-fixes-v2-2-ca652d55fd4a@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="612169"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:YYvs8fYYIUdnf125wfPPB/lXbxY= sha256:+ywu2+VCYcZ8t9vQZJNzwbDT73hW0RP2pINYSYTYEck=
	sha1:eb28LPw/Vvy6+PGeySxoRxG/BjQ= sha256:1ymm66GLWsl02miAmNTEwhqI4RdSeQxhZTE6uMEVqTA=
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 DBE2610F11E; Wed,  7 Oct 2026 11:58:58 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -0.992
X-Spam-Status: No, score=-0.992 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.241, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	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 VHIiEoih5pZw;
	Wed,  7 Oct 2026 11:58:56 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-342273-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 2194B10F11A; Wed,  7 Oct 2026 11:58:52 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by sin.lore.kernel.org (Postfix) with ESMTP id 5A7D625FD4; Wed,  7 Oct 2026 08:58:37 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 1D1F745A2AA;
	Wed,  7 Oct 2026 08:58:35 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="HphPBdON"
X-Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108])
	(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 760553D812A;
	Wed,  7 Oct 2026 08:58:33 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1791363515; cv=none; b=c968AD+miHfJc4Q2LJQ+F/1KVft5SDWPP/uF8qBksqbpFhxUp1zGCFaPMpg1o70nNQraTS02BrRzr+5eX7hD0dyRcLaPep4mzW2FPB9cICALfpfHCjK7jqvkDyj0ntxpBV6lD1L99mWnvW+LitDBUFKqlM5eug0OZPkjhiuf71I=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1791363515; c=relaxed/simple;
	bh=q08rdZ3vOXEzVVRiBycbO7Wq7m1ZTqO5mAiKoAuBmKQ=;
	h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:
	 Content-Type:Content-Disposition:In-Reply-To; b=TrOo/VAQc/cRZydvhrtAJviX36o3MwgQ9m7t9sga61oi4F3DvAxrWf9XCN5iyZiGhhpsqwGMDqAS/ut2Ne8JP0KuNmvVIjJ/pMIAUVe2di09UqgbG3IwwCckB8Cg8L7bwFNz26TJuGwXcAjRYoJeHVjLZZzZwtbPgOdP0jF8J/8=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=HphPBdON; arc=none smtp.client-ip=82.195.75.108
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=apMsyzvREPGcbRioTUNx1bwvtoun0JTuglsS9LHwric=; b=HphPBdONNvFlva9mcCQThwAa4a
	nI4QlMNZ9+R9E97yHBMI5U1EDrVj7WIO/MJsqDYQoMG9H2CvZHNhoIBgoo3zG4rhGc3R80d5UPF/o
	j3dT7F8nANmeQ5N7BzouEik6E9x2uJWVmxUMGJmmwL3wJrFBN565QbnthGnURmopzQ/gGBrhzM+r7
	8h0ELLP0MUGi8gFp9vguGYcYj1HZKUpwLB3zBjAIEy10eLVzIfKhcyCV4D2Tro3YG+sX+9wCBtk+8
	PItsIprK/ovRi897QXaRU1htHG4lAyNwtUMwea6ucWs+Fa1D9VRp4MjfoB+grIIeLtkD9dOjQWzqs
	pnvIQ2Cg==;
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 1xENTk-004dDg-12;
	Wed, 07 Oct 2026 08:58:24 +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-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-In-Reply-To: <20261006-netcons-fixes-v2-2-ca652d55fd4a@gmail.com>
X-Debian-User: leitao