* [PATCH] netconsole configfs target release NULL dereference
@ 2026-07-17 10:39 David Lee
2026-07-17 12:29 ` Breno Leitao
0 siblings, 1 reply; 2+ messages in thread
From: David Lee @ 2026-07-17 10:39 UTC (permalink / raw)
To: Breno Leitao
Cc: David Lee, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, netdev,
Dominik 'Disconnect3d' Czarnota, linux-kernel
configfs target release can call netpoll cleanup with missing netpoll state.
Mark targets as disabled before releasing their netpoll state and skip
cleanup when no netpoll device is present. This prevents teardown races
from reaching netpoll cleanup after nt->np.dev has already been cleared.
Fixes: 97714695ef90 ("net: netconsole: Defer netpoll cleanup to avoid lock release during list traversal")
Signed-off-by: David Lee <david.lee@trailofbits.com>
Assisted-by: Codex:gpt-5.5
---
drivers/net/netconsole.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 862001d..ad30e2e 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -287,6 +287,8 @@ static bool bound_by_mac(struct netconsole_target *nt)
static void netcons_release_dev(struct netconsole_target *nt)
{
+ if (!nt->np.dev)
+ return;
do_netpoll_cleanup(&nt->np);
if (bound_by_mac(nt))
memset(&nt->np.dev_name, 0, IFNAMSIZ);
@@ -1490,10 +1492,12 @@ static void drop_netconsole_target(struct config_group *group,
*/
needs_cleanup = nt->state == STATE_ENABLED ||
nt->state == STATE_DEACTIVATED;
- /* Disable deactivated target to prevent races between resume attempt
- * and target removal.
+ /* Disable targets that still own netpoll state before removal. This
+ * prevents races between open configfs writers, resume attempts, and
+ * target removal from observing STATE_ENABLED after netpoll_cleanup()
+ * has cleared nt->np.dev.
*/
- if (nt->state == STATE_DEACTIVATED)
+ if (needs_cleanup)
nt->state = STATE_DISABLED;
list_del(&nt->list);
spin_unlock_irqrestore(&target_list_lock, flags);
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] netconsole configfs target release NULL dereference
2026-07-17 10:39 [PATCH] netconsole configfs target release NULL dereference David Lee
@ 2026-07-17 12:29 ` Breno Leitao
0 siblings, 0 replies; 2+ messages in thread
From: Breno Leitao @ 2026-07-17 12:29 UTC (permalink / raw)
To: David Lee
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, netdev, Dominik 'Disconnect3d' Czarnota,
linux-kernel
Hello David,
On Fri, Jul 17, 2026 at 10:39:02AM +0000, David Lee wrote:
> configfs target release can call netpoll cleanup with missing netpoll state.
>
> Mark targets as disabled before releasing their netpoll state and skip
> cleanup when no netpoll device is present. This prevents teardown races
> from reaching netpoll cleanup after nt->np.dev has already been cleared.
>
> Fixes: 97714695ef90 ("net: netconsole: Defer netpoll cleanup to avoid lock release during list traversal")
> Signed-off-by: David Lee <david.lee@trailofbits.com>
> Assisted-by: Codex:gpt-5.5
> ---
>
> drivers/net/netconsole.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
> index 862001d..ad30e2e 100644
> --- a/drivers/net/netconsole.c
> +++ b/drivers/net/netconsole.c
> @@ -287,6 +287,8 @@ static bool bound_by_mac(struct netconsole_target *nt)
>
> static void netcons_release_dev(struct netconsole_target *nt)
> {
> + if (!nt->np.dev)
> + return;
I am not sure we get here with nt->np.dev unset, otherwise it will
panic in the next lines:
netcons_release_dev() calls do_netpoll_cleanup(), which calls calls
__netpoll_cleanup() which dereferences dev, as in:
static void __netpoll_cleanup(struct netpoll *np)
...
npinfo = rtnl_dereference(np->dev->npinfo);
Are you hitting this NULL pointer dereference, thus, we need the early
return above?
Thanks for the patch,
--breno
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-17 12:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-17 10:39 [PATCH] netconsole configfs target release NULL dereference David Lee
2026-07-17 12:29 ` Breno Leitao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox