• Breno Leitao's avatar
    net: netconsole: Defer netpoll cleanup to avoid lock release during list traversal · 97714695
    Breno Leitao authored
    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 b5427c27 ("[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: default avatarBreno Leitao <leitao@debian.org>
    Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
    97714695
netconsole.c 34.9 KB