mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Zihan Xi <zihanx@nebusec.ai>
Cc: netdev@vger.kernel.org, "David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	Vega <vega@nebusec.ai>
Subject: Re: [PATCH net 1/1] net: fix linkwatch UAF on uninitialized netdev
Date: Tue, 8 Sep 2026 18:54:51 -0700	[thread overview]
Message-ID: <20260908185451.73a49bbd@kernel.org> (raw)
In-Reply-To: <eeaeddc20bf5382336eaf704b5b15e3780dbb768.1788500348.git.zihanx@nebusec.ai>

On Fri,  4 Sep 2026 06:46:44 +0000 Zihan Xi wrote:
> linkwatch_fire_event() queues a net_device onto lweventlist and takes a
> netdev_hold() even when the device has never been registered.
> 
> netif_carrier_on(), netif_carrier_off() and netif_carrier_event() already
> skip NETREG_UNINITIALIZED. netif_dormant_*() and netif_testing_*() do
> not. Pre-registration operstate changes are meant to stay local and be
> consumed later by linkwatch_init_dev() in register_netdevice().
> 
> If a driver fires a dormant or testing event before register_netdevice()
> and registration then fails, rtnl_newlink_create() calls free_netdev().
> For NETREG_UNINITIALIZED devices, free_netdev() immediately kvfree()s
> the object without draining linkwatch. The later linkwatch worker
> dereferences the stale list entry and use-after-frees the device.
> 
> The same path is reachable from an unprivileged user who can unshare
> user and net namespaces, because only netns-local CAP_NET_ADMIN is
> required.
> 
> linkwatch_fire_event() has never rejected NETREG_UNINITIALIZED devices.
> That goes back to commit 1da177e4c3f4 ("Linux-2.6.12-rc2"), the root of
> this tree. Later changes only altered callers or were reverted.
> 
> commit b47300168e77 ("net: Do not fire linkwatch events
> until the device is registered.")
> skipped uninitialized devices in the carrier helpers only.
> 
> commit 22604c866889 ("net: Fix for initial link state in 2.6.28")
> briefly added a NETREG_UNINITIALIZED return in the helper after calling
> rfc2863_policy().
> 
> commit c276e098d3ee ("Revert "net: Fix for initial link state in 2.6.28"")
> removed it again because that rfc2863_policy() call could take
> dev_base_lock in software-interrupt context.
> 
> Fix this in linkwatch_fire_event() by ignoring NETREG_UNINITIALIZED
> devices so they cannot be queued, without calling rfc2863_policy().
> Pre-registration flags remain on the device and are still applied by
> linkwatch_init_dev() if registration succeeds.

This commit message seems to be quite low quality.
It reads like the LLM was following some check box list rather than
allowed to think. From the bug report in cover letter the problem
seems to be that one caller (wifi test harness device) fires a
linkwatch even too early. And you think that the fix is to change 
the core helper to silently ignore this event? Just fix the buggy
driver?? Or if you think there's more than one such driver please
provide more info.

> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")

Since your trigger didn't exist in 2.6.12 I'm not sure why you're
pointing at that commit.

FTR, the quality of the repro is also looking like a year+ old model
following a checklist:

  This is an rtnetlink RTM_NEWLINK creation path, not a packet-sequence
  or protocol-state trigger. packetdrill cannot express creating a dummy
  lower device...

Please get a better model.

      reply	other threads:[~2026-09-09  1:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04  6:46 [PATCH net 0/1] " Zihan Xi
2026-09-04  6:46 ` [PATCH net 1/1] " Zihan Xi
2026-09-09  1:54   ` Jakub Kicinski [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=20260908185451.73a49bbd@kernel.org \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=vega@nebusec.ai \
    --cc=zihanx@nebusec.ai \
    /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®