linux-stable/net/rxrpc
David Howells 92128a7170 rxrpc: Fix timeout of a call that hasn't yet been granted a channel
[ Upstream commit db099c625b ]

afs_make_call() calls rxrpc_kernel_begin_call() to begin a call (which may
get stalled in the background waiting for a connection to become
available); it then calls rxrpc_kernel_set_max_life() to set the timeouts -
but that starts the call timer so the call timer might then expire before
we get a connection assigned - leading to the following oops if the call
stalled:

	BUG: kernel NULL pointer dereference, address: 0000000000000000
	...
	CPU: 1 PID: 5111 Comm: krxrpcio/0 Not tainted 6.3.0-rc7-build3+ #701
	RIP: 0010:rxrpc_alloc_txbuf+0xc0/0x157
	...
	Call Trace:
	 <TASK>
	 rxrpc_send_ACK+0x50/0x13b
	 rxrpc_input_call_event+0x16a/0x67d
	 rxrpc_io_thread+0x1b6/0x45f
	 ? _raw_spin_unlock_irqrestore+0x1f/0x35
	 ? rxrpc_input_packet+0x519/0x519
	 kthread+0xe7/0xef
	 ? kthread_complete_and_exit+0x1b/0x1b
	 ret_from_fork+0x22/0x30

Fix this by noting the timeouts in struct rxrpc_call when the call is
created.  The timer will be started when the first packet is transmitted.

It shouldn't be possible to trigger this directly from userspace through
AF_RXRPC as sendmsg() will return EBUSY if the call is in the
waiting-for-conn state if it dropped out of the wait due to a signal.

Fixes: 9d35d880e0 ("rxrpc: Move client call connection to the I/O thread")
Reported-by: Marc Dionne <marc.dionne@auristor.com>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: "David S. Miller" <davem@davemloft.net>
cc: Eric Dumazet <edumazet@google.com>
cc: Jakub Kicinski <kuba@kernel.org>
cc: Paolo Abeni <pabeni@redhat.com>
cc: linux-afs@lists.infradead.org
cc: netdev@vger.kernel.org
cc: linux-kernel@vger.kernel.org
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-05-17 13:58:47 +02:00
..
Kconfig rxrpc: Implement an in-kernel rxperf server for testing purposes 2022-12-01 13:36:37 +00:00
Makefile rxrpc: Split out the call state changing functions into their own file 2023-01-06 09:43:32 +00:00
af_rxrpc.c rxrpc: Fix timeout of a call that hasn't yet been granted a channel 2023-05-17 13:58:47 +02:00
ar-internal.h rxrpc: Fix timeout of a call that hasn't yet been granted a channel 2023-05-17 13:58:47 +02:00
call_accept.c rxrpc: Fix incoming call setup race 2023-01-07 09:30:26 +00:00
call_event.c rxrpc: Remove call->state_lock 2023-01-06 09:43:33 +00:00
call_object.c rxrpc: Fix timeout of a call that hasn't yet been granted a channel 2023-05-17 13:58:47 +02:00
call_state.c rxrpc: Move client call connection to the I/O thread 2023-01-06 09:43:33 +00:00
conn_client.c rxrpc: Move client call connection to the I/O thread 2023-01-06 09:43:33 +00:00
conn_event.c rxrpc: Move client call connection to the I/O thread 2023-01-06 09:43:33 +00:00
conn_object.c rxrpc: Move client call connection to the I/O thread 2023-01-06 09:43:33 +00:00
conn_service.c rxrpc: Move client call connection to the I/O thread 2023-01-06 09:43:33 +00:00
input.c rxrpc: Remove call->state_lock 2023-01-06 09:43:33 +00:00
insecure.c rxrpc: Tidy up abort generation infrastructure 2023-01-06 09:43:32 +00:00
io_thread.c rxrpc: Move client call connection to the I/O thread 2023-01-06 09:43:33 +00:00
key.c rxrpc: Fix error when reading rxrpc tokens 2023-05-11 23:11:19 +09: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: Move client call connection to the I/O thread 2023-01-06 09:43:33 +00:00
misc.c rxrpc: Get rid of the Rx ring 2022-11-08 16:42:28 +00:00
net_ns.c rxrpc: Move the client conn cache management to the I/O thread 2023-01-06 09:43:33 +00:00
output.c rxrpc: Remove call->state_lock 2023-01-06 09:43:33 +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: Stash the network namespace pointer in rxrpc_local 2023-01-06 09:43:31 +00:00
proc.c rxrpc: Move client call connection to the I/O thread 2023-01-06 09:43:33 +00:00
protocol.h rxrpc: Clone received jumbo subpackets and queue separately 2022-11-08 16:42:28 +00:00
recvmsg.c rxrpc: Move call state changes from recvmsg to I/O thread 2023-01-06 09:43:33 +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: Move client call connection to the I/O thread 2023-01-06 09:43:33 +00:00
rxperf.c rxrpc: Tidy up abort generation infrastructure 2023-01-06 09:43:32 +00:00
security.c rxrpc: Fix incoming call setup race 2023-01-07 09:30:26 +00:00
sendmsg.c rxrpc: Fix timeout of a call that hasn't yet been granted a channel 2023-05-17 13:58:47 +02: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