mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Breno Leitao <leitao@debian.org>
To: Gustavo Luiz Duarte <gustavold@gmail.com>
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
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	[thread overview]
Message-ID: <asYJRc4mU1qUrdgQ@gmail.com> (raw)
In-Reply-To: <20261006-netcons-fixes-v2-2-ca652d55fd4a@gmail.com>

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

      reply	other threads:[~2026-10-07  8:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-06 18:21 [PATCH net v2 0/2] netconsole: fix target enable race and configfs read locking Gustavo Luiz Duarte
2026-10-06 18:21 ` [PATCH net v2 1/2] netconsole: finish enabling the target before releasing RTNL Gustavo Luiz Duarte
2026-10-06 18:21 ` [PATCH net v2 2/2] netconsole: read np.dev under the RTNL in local_mac_show() Gustavo Luiz Duarte
2026-10-07  8:58   ` Breno Leitao [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=asYJRc4mU1qUrdgQ@gmail.com \
    --to=leitao@debian.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=gustavold@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®