]> www.infradead.org Git - users/dwmw2/linux.git/commit
net: netconsole: Defer netpoll cleanup to avoid lock release during list traversal
authorBreno Leitao <leitao@debian.org>
Thu, 8 Aug 2024 12:25:11 +0000 (05:25 -0700)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 13 Aug 2024 08:58:58 +0000 (10:58 +0200)
commit97714695ef904a4bdba75ca2f339215c0ae2b1fa
tree80b2b6a30cb2a326778c8cb0f1860a88646c6fee
parentf2ab4c1a9288774b1f9c102f0cb1b478965169bb
net: netconsole: Defer netpoll cleanup to avoid lock release during list traversal

Current issue:
- The `target_list_lock` spinlock is held while iterating over
  target_list() entries.
- Mid-loop, the lock is released to call __netpoll_cleanup(), then
  reacquired.
- This practice compromises the protection provided by
  `target_list_lock`.

Reason for current design:
1. __netpoll_cleanup() may sleep, incompatible with holding a spinlock.
2. target_list_lock must be a spinlock because write_msg() cannot sleep.
   (See commit b5427c27173e ("[NET] netconsole: Support multiple logging
    targets"))

Defer the cleanup of the netpoll structure to outside the
target_list_lock() protected area. Create another list
(target_cleanup_list) to hold the entries that need to be cleaned up,
and clean them using a mutex (target_cleanup_list_lock).

Signed-off-by: Breno Leitao <leitao@debian.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/netconsole.c