linux-stable/net/rxrpc
David Howells 8cbf4ae7a2 rxrpc: Fix call timer start racing with call destruction
commit 4a7f62f919 upstream.

The rxrpc_call struct has a timer used to handle various timed events
relating to a call.  This timer can get started from the packet input
routines that are run in softirq mode with just the RCU read lock held.
Unfortunately, because only the RCU read lock is held - and neither ref or
other lock is taken - the call can start getting destroyed at the same time
a packet comes in addressed to that call.  This causes the timer - which
was already stopped - to get restarted.  Later, the timer dispatch code may
then oops if the timer got deallocated first.

Fix this by trying to take a ref on the rxrpc_call struct and, if
successful, passing that ref along to the timer.  If the timer was already
running, the ref is discarded.

The timer completion routine can then pass the ref along to the call's work
item when it queues it.  If the timer or work item where already
queued/running, the extra ref is discarded.

Fixes: a158bdd324 ("rxrpc: Fix call timeouts")
Reported-by: Marc Dionne <marc.dionne@auristor.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Marc Dionne <marc.dionne@auristor.com>
Tested-by: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
Link: http://lists.infradead.org/pipermail/linux-afs/2022-March/005073.html
Link: https://lore.kernel.org/r/164865115696.2943015.11097991776647323586.stgit@warthog.procyon.org.uk
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-04-08 14:24:10 +02:00
..
af_rxrpc.c rxrpc: Fix fall-through warnings for Clang 2021-06-04 17:40:04 -05:00
ar-internal.h rxrpc: Fix call timer start racing with call destruction 2022-04-08 14:24:10 +02:00
call_accept.c rxrpc: Fix memory leak in rxrpc_lookup_local 2021-01-28 13:12:14 -08:00
call_event.c rxrpc: Fix call timer start racing with call destruction 2022-04-08 14:24:10 +02:00
call_object.c rxrpc: Fix call timer start racing with call destruction 2022-04-08 14:24:10 +02:00
conn_client.c rxrpc: Fix rxrpc_peer leak in rxrpc_look_up_bundle() 2021-12-08 09:04:48 +01:00
conn_event.c rxrpc: Merge prime_packet_security into init_connection_security 2020-11-23 18:09:30 +00:00
conn_object.c rxrpc: Ask the security class how much space to allow in a packet 2020-11-23 19:53:11 +00:00
conn_service.c rxrpc: Don't retain the server key in the connection 2020-11-23 18:09:29 +00:00
input.c rxrpc: Call state should be read with READ_ONCE() under some circumstances 2021-01-13 10:38:20 -08:00
insecure.c rxrpc: Ask the security class how much space to allow in a packet 2020-11-23 19:53:11 +00:00
Kconfig net: RxRPC: make dependent Kconfig symbols be shown indented 2021-08-18 10:12:11 +01:00
key.c rxrpc: Fix handling of an unsupported token type in rxrpc_read() 2021-01-13 10:38:00 -08:00
local_event.c rxrpc: Fix a typo 2021-06-02 14:01:55 -07:00
local_object.c rxrpc: Fix dependency on IPv6 in udp tunnel config 2021-02-12 16:42:05 -08:00
Makefile rxrpc: Split the server key type (rxrpc_s) into its own file 2020-11-23 18:09:29 +00:00
misc.c
net_ns.c
output.c rxrpc: Adjust retransmission backoff 2022-02-01 17:27:11 +01:00
peer_event.c
peer_object.c rxrpc: Fix rxrpc_local leak in rxrpc_lookup_peer() 2021-12-08 09:04:49 +01:00
proc.c
protocol.h
recvmsg.c afs: Don't truncate iter during data fetch 2021-04-23 10:17:26 +01:00
rtt.c rxrpc: Fix _usecs_to_jiffies() by using usecs_to_jiffies() 2021-11-18 19:16:25 +01:00
rxkad.c rxrpc: rxkad: Remove redundant variable offset 2021-04-27 14:05:06 -07:00
security.c rxrpc: Hand server key parsing off to the security class 2020-11-23 18:09:29 +00:00
sendmsg.c rxrpc: Ask the security class how much space to allow in a packet 2020-11-23 19:53:11 +00:00
server_key.c rxrpc: fix some null-ptr-deref bugs in server_key.c 2022-04-08 14:24:10 +02:00
skbuff.c
sysctl.c
utils.c