Skip to content

Commit 97d9fba

Browse files
leitaokuba-moo
authored andcommitted
net: netconsole: Disable target before netpoll cleanup
Currently, netconsole cleans up the netpoll structure before disabling the target. This approach can lead to race conditions, as message senders (write_ext_msg() and write_msg()) check if the target is enabled before using netpoll. The sender can validate that the target is enabled, but, the netpoll might be de-allocated already, causing undesired behaviours. This patch reverses the order of operations: 1. Disable the target 2. Clean up the netpoll structure This change eliminates the potential race condition, ensuring that no messages are sent through a partially cleaned-up netpoll structure. Fixes: 2382b15 ("netconsole: take care of NETDEV_UNREGISTER event") Cc: [email protected] Signed-off-by: Breno Leitao <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent d657f5c commit 97d9fba

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/net/netconsole.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -974,14 +974,14 @@ static int netconsole_netdev_event(struct notifier_block *this,
974974
/* rtnl_lock already held
975975
* we might sleep in __netpoll_cleanup()
976976
*/
977+
nt->enabled = false;
977978
spin_unlock_irqrestore(&target_list_lock, flags);
978979

979980
__netpoll_cleanup(&nt->np);
980981

981982
spin_lock_irqsave(&target_list_lock, flags);
982983
netdev_put(nt->np.dev, &nt->np.dev_tracker);
983984
nt->np.dev = NULL;
984-
nt->enabled = false;
985985
stopped = true;
986986
netconsole_target_put(nt);
987987
goto restart;

0 commit comments

Comments
 (0)