• David Howells's avatar
    rxrpc: Fix I/O thread stop · 743d1768
    David Howells authored
    The rxrpc I/O thread checks to see if there's any work it needs to do, and
    if not, checks kthread_should_stop() before scheduling, and if it should
    stop, breaks out of the loop and tries to clean up and exit.
    
    This can, however, race with socket destruction, wherein outstanding calls
    are aborted and released from the socket and then the socket unuses the
    local endpoint, causing kthread_stop() to be issued.  The abort is deferred
    to the I/O thread and the event can by issued between the I/O thread
    checking if there's any work to be done (such as processing call aborts)
    and the stop being seen.
    
    This results in the I/O thread stopping processing of events whilst call
    cleanup events are still outstanding, leading to connections or other
    objects still being around and uncleaned up, which can result in assertions
    being triggered, e.g.:
    
        rxrpc: AF_RXRPC: Leaked client conn 00000000e8009865 {2}
        ------------[ cut here ]------------
        kernel BUG at net/rxrpc/conn_client.c:64!
    
    Fix this by retrieving the kthread_should_stop() indication, then checking
    to see if there's more work to do, and going back round the loop if there
    is, and breaking out of the loop only if there wasn't.
    
    This was triggered by a syzbot test that produced some other symptom[1].
    
    Fixes: a275da62 ("rxrpc: Create a per-local endpoint receive queue and I/O thread")
    Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
    cc: Marc Dionne <marc.dionne@auristor.com>
    cc: linux-afs@lists.infradead.org
    Link: https://lore.kernel.org/r/0000000000002b4a9f05ef2b616f@google.com/ [1]
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    743d1768
io_thread.c 12.4 KB