mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: SeungJong Ha <engineer.jjhama@gmail.com>
To: "David S. Miller" <davem@davemloft.net>,
	 Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
	 Neil Horman <nhorman@tuxdriver.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	 stable@vger.kernel.org, SeungJong Ha <engineer.jjhama@gmail.com>
Subject: [PATCH net] net: release netpoll dev_lock when NETDEV_PRE_UP vetoes an open
Date: Wed, 18 Nov 2026 15:27:44 +0900	[thread overview]
Message-ID: <20261118-netpoll-preup-veto-v1-1-7d3fdf101d3a@gmail.com> (raw)

When netpoll is attached to a device, __dev_open() takes
npinfo->dev_lock through netpoll_poll_disable() before calling the
NETDEV_PRE_UP notifiers, but returns without releasing it when a
notifier vetoes the open. The next attempt to open the device then
sleeps in down() with RTNL held, and every other RTNL user blocks
behind it.

For example, with netconsole on a wireless interface, cfg80211 vetoes
the open while the wiphy is rfkill-blocked. Release the lock on that
path, as the ndo_open() error path does.

Found by an AI coding assistant reviewing __dev_open(). Reproduced in
QEMU on an unmodified net tree with mac80211_hwsim built in and
netconsole bound to wlan0:

  ip link set wlan0 down
  echo 1 > /sys/class/ieee80211/phy0/rfkill0/soft
  ip link set wlan0 up    # fails: RF-kill
  echo 0 > /sys/class/ieee80211/phy0/rfkill0/soft
  ip link set wlan0 up    # hangs in D state:
    down
    __dev_open
    __dev_change_flags
    netif_change_flags
    do_setlink

With this patch the last command succeeds. Selftests were not run.

Fixes: ca99ca14c95a ("netpoll: protect napi_poll and poll_controller during dev_[open|close]")
Cc: stable@vger.kernel.org
Signed-off-by: SeungJong Ha <engineer.jjhama@gmail.com>
---
The fix just drops the lock on the veto path, the same way the
ndo_open() error path a few lines below already does.

I tested it in QEMU on net (297ae1590173) with mac80211_hwsim and
netconsole built in: the reproducer from the commit message hangs
without the patch and completes with it. W=1 allyesconfig and
allmodconfig builds are clean for net/core/dev.c.

The bug was found, and the reproducer and patch written, with Claude
Code (Claude Opus 5.5). I reviewed all of it by hand and re-ran the
reproducer myself.
---
 net/core/dev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 3c58db732761..0be9e78572ff 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1748,8 +1748,10 @@ static int __dev_open(struct net_device *dev, struct netlink_ext_ack *extack)
 
 	ret = call_netdevice_notifiers_extack(NETDEV_PRE_UP, dev, extack);
 	ret = notifier_to_errno(ret);
-	if (ret)
+	if (ret) {
+		netpoll_poll_enable(dev);
 		return ret;
+	}
 
 	set_bit(__LINK_STATE_START, &dev->state);
 

---
base-commit: 297ae15901733df7562a6781613fb49f3d270401
change-id: 20261117-netpoll-preup-veto-943045f4616b

Best regards,
--  
SeungJong Ha <engineer.jjhama@gmail.com>


                 reply	other threads:[~2026-11-18  6:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261118-netpoll-preup-veto-v1-1-7d3fdf101d3a@gmail.com \
    --to=engineer.jjhama@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@tuxdriver.com \
    --cc=pabeni@redhat.com \
    --cc=stable@vger.kernel.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®