linux-stable/net/sunrpc
Benjamin Coddington e9f076b9a1 SUNRPC: Fix a race to wake a sync task
[ Upstream commit ed0172af5d ]

We've observed NFS clients with sync tasks sleeping in __rpc_execute
waiting on RPC_TASK_QUEUED that have not responded to a wake-up from
rpc_make_runnable().  I suspect this problem usually goes unnoticed,
because on a busy client the task will eventually be re-awoken by another
task completion or xprt event.  However, if the state manager is draining
the slot table, a sync task missing a wake-up can result in a hung client.

We've been able to prove that the waker in rpc_make_runnable() successfully
calls wake_up_bit() (ie- there's no race to tk_runstate), but the
wake_up_bit() call fails to wake the waiter.  I suspect the waker is
missing the load of the bit's wait_queue_head, so waitqueue_active() is
false.  There are some very helpful comments about this problem above
wake_up_bit(), prepare_to_wait(), and waitqueue_active().

Fix this by inserting smp_mb__after_atomic() before the wake_up_bit(),
which pairs with prepare_to_wait() calling set_current_state().

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-08-14 13:52:49 +02:00
..
auth_gss gss_krb5: Fix the error handling path for crypto_sync_skcipher_setkey 2024-08-03 08:49:08 +02:00
xprtrdma xprtrdma: Fix rpcrdma_reqs_reset() 2024-08-03 08:49:15 +02:00
addr.c net: sunrpc: Fix an off by one in rpc_sockaddr2uaddr() 2024-03-26 18:20:55 -04:00
auth.c
auth_null.c
auth_unix.c
backchannel_rqst.c
cache.c
clnt.c SUNRPC: avoid soft lockup when transmitting UDP to reachable server. 2024-08-03 08:49:15 +02:00
debugfs.c
fail.h
Kconfig
Makefile
netns.h
rpc_pipe.c
rpcb_clnt.c SUNRPC: Add an IS_ERR() check back to where it was 2023-11-28 17:07:03 +00:00
sched.c SUNRPC: Fix a race to wake a sync task 2024-08-14 13:52:49 +02:00
socklib.c use less confusing names for iov_iter direction initializers 2023-02-09 11:28:04 +01:00
socklib.h
stats.c
sunrpc.h
sunrpc_syms.c
svc.c sunrpc: removed redundant procp check 2024-06-12 11:03:30 +02:00
svc_xprt.c nfsd: don't allow nfsd threads to be signalled. 2024-05-25 16:21:30 +02:00
svcauth.c
svcauth_unix.c sunrpc: only free unix grouplist after RCU settles 2023-04-13 16:55:23 +02:00
svcsock.c SUNRPC: Fix UAF in svc_tcp_listen_data_ready() 2023-07-19 16:21:48 +02:00
sysctl.c
sysfs.c SUNRPC: Fix null-ptr-deref when xps sysfs alloc failed 2022-10-27 15:52:10 -04:00
sysfs.h
timer.c
xdr.c
xprt.c timers: Get rid of del_singleshot_timer_sync() 2024-05-17 11:56:12 +02:00
xprtmultipath.c SUNRPC: Fix a suspicious RCU usage warning 2024-02-05 20:12:49 +00:00
xprtsock.c net, sunrpc: Remap EPERM in case of connection failure in xs_tcp_setup_socket 2024-07-18 13:18:35 +02:00