Thread (2 messages) flat view 2 messages, 2 authors, 2026-01-30

Re: [PATCH net-next v1] linkwatch: hold dev reference to prevent UAF in __linkwatch_run_queue()

From: Jakub Kicinski <kuba@kernel.org>
Date: 2026-01-30 03:09:20
Also in: lkml

On Wed, 28 Jan 2026 11:10:07 +0800 Jiayuan Chen wrote:
Subject: [PATCH net-next v1] linkwatch: hold dev reference to prevent UAF in __linkwatch_run_queue()
please use net rather than net-next for fixes.
 		netdev_tracker_free(dev, &dev->linkwatch_dev_tracker);
 		spin_unlock_irq(&lweventlist_lock);
+
+		/*
+		 * Hold extra reference to protect netdev_unlock_ops().
+		 * linkwatch_do_dev() calls __dev_put() which releases
+		 * the linkwatch reference. Without this extra hold,
+		 * the device could be freed by netdev_run_todo() before
+		 * we call netdev_unlock_ops().
+		 */
+		__dev_hold(dev);
 		netdev_lock_ops(dev);
 		linkwatch_do_dev(dev);
 		netdev_unlock_ops(dev);
+		__dev_put(dev);
Please move the dev_put() from inside linkwatch_do_dev() out to its
(3) callers, instead of taking another ref. The dev_put() inside
linkwatch_do_dev() logically pairs with de-listing the device so
it's reasonable for the caller that did the de-listing to do it.
(of course that'll let you move it after the unlock)
-- 
pw-bot: cr
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help