linux/net/rxrpc
David Howells 743d1768a0 rxrpc: Fix I/O thread stop
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: a275da62e8 ("rxrpc: Create a per-local endpoint receive queue and I/O thread")
Signed-off-by: David 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: David S. Miller <davem@davemloft.net>
2022-12-19 09:51:31 +00:00
..
af_rxrpc.c rxrpc: Remove the _bh annotation from all the spinlocks 2022-12-01 13:36:42 +00:00
ar-internal.h rxrpc: Fix locking issues in rxrpc_put_peer_locked() 2022-12-19 09:51:31 +00:00
call_accept.c rxrpc: Remove the _bh annotation from all the spinlocks 2022-12-01 13:36:42 +00:00
call_event.c rxrpc: Transmit ACKs at the point of generation 2022-12-01 13:36:43 +00:00
call_object.c rxrpc: Fix security setting propagation 2022-12-19 09:51:31 +00:00
conn_client.c rxrpc: Fix security setting propagation 2022-12-19 09:51:31 +00:00
conn_event.c rxrpc: Remove the _bh annotation from all the spinlocks 2022-12-01 13:36:42 +00:00
conn_object.c rxrpc: Make the I/O thread take over the call and local processor work 2022-12-01 13:36:42 +00:00
conn_service.c rxrpc: Remove the _bh annotation from all the spinlocks 2022-12-01 13:36:42 +00:00
input.c rxrpc: Move the cwnd degradation after transmitting packets 2022-12-01 13:36:43 +00:00
insecure.c rxrpc: Don't use a ring buffer for call Tx queue 2022-11-08 16:42:28 +00:00
io_thread.c rxrpc: Fix I/O thread stop 2022-12-19 09:51:31 +00:00
Kconfig rxrpc: Implement an in-kernel rxperf server for testing purposes 2022-12-01 13:36:37 +00:00
key.c rxrpc: Drop rxrpc_conn_parameters from rxrpc_connection and rxrpc_bundle 2022-12-01 13:36:38 +00:00
local_event.c rxrpc: Make the I/O thread take over the call and local processor work 2022-12-01 13:36:42 +00:00
local_object.c rxrpc: Fix I/O thread startup getting skipped 2022-12-19 09:51:31 +00:00
Makefile rxrpc: Split the receive code 2022-12-01 13:36:40 +00:00
misc.c rxrpc: Get rid of the Rx ring 2022-11-08 16:42:28 +00:00
net_ns.c rxrpc: Don't hold a ref for connection workqueue 2022-12-01 13:36:40 +00:00
output.c rxrpc: Transmit ACKs at the point of generation 2022-12-01 13:36:43 +00:00
peer_event.c rxrpc: Fix locking issues in rxrpc_put_peer_locked() 2022-12-19 09:51:31 +00:00
peer_object.c rxrpc: Fix switched parameters in peer tracing 2022-12-19 09:51:31 +00:00
proc.c rxrpc: Move the cwnd degradation after transmitting packets 2022-12-01 13:36:43 +00:00
protocol.h rxrpc: Clone received jumbo subpackets and queue separately 2022-11-08 16:42:28 +00:00
recvmsg.c rxrpc: Transmit ACKs at the point of generation 2022-12-01 13:36:43 +00:00
rtt.c rxrpc: Fix _usecs_to_jiffies() by using usecs_to_jiffies() 2021-09-24 14:18:34 +01:00
rxkad.c rxrpc: Drop rxrpc_conn_parameters from rxrpc_connection and rxrpc_bundle 2022-12-01 13:36:38 +00:00
rxperf.c rxrpc: Implement an in-kernel rxperf server for testing purposes 2022-12-01 13:36:37 +00:00
security.c rxrpc: Fix security setting propagation 2022-12-19 09:51:31 +00:00
sendmsg.c rxrpc: Fix missing unlock in rxrpc_do_sendmsg() 2022-12-19 09:51:31 +00:00
server_key.c rxrpc: Implement an in-kernel rxperf server for testing purposes 2022-12-01 13:36:37 +00:00
skbuff.c rxrpc: trace: Don't use __builtin_return_address for sk_buff tracing 2022-12-01 13:36:39 +00:00
sysctl.c rxrpc: Get rid of the Rx ring 2022-11-08 16:42:28 +00:00
txbuf.c rxrpc: Transmit ACKs at the point of generation 2022-12-01 13:36:43 +00:00
utils.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 36 2019-05-24 17:27:11 +02:00