Skip to content

Commit 5bbd6e8

Browse files
Trond MyklebustAnna Schumaker
authored andcommitted
SUNRPC: Prevent looping due to rpc_signal_task() races
If rpc_signal_task() is called while a task is in an rpc_call_done() callback function, and the latter calls rpc_restart_call(), the task can end up looping due to the RPC_TASK_SIGNALLED flag being set without the tk_rpc_status being set. Removing the redundant mechanism for signalling the task fixes the looping behaviour. Reported-by: Li Lingfeng <[email protected]> Fixes: 3949419 ("SUNRPC: Fix races with rpc_killall_tasks()") Signed-off-by: Trond Myklebust <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 88025c6 commit 5bbd6e8

File tree

3 files changed

+2
-6
lines changed

3 files changed

+2
-6
lines changed

include/linux/sunrpc/sched.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ enum {
158158
RPC_TASK_NEED_XMIT,
159159
RPC_TASK_NEED_RECV,
160160
RPC_TASK_MSG_PIN_WAIT,
161-
RPC_TASK_SIGNALLED,
162161
};
163162

164163
#define rpc_test_and_set_running(t) \
@@ -171,7 +170,7 @@ enum {
171170

172171
#define RPC_IS_ACTIVATED(t) test_bit(RPC_TASK_ACTIVE, &(t)->tk_runstate)
173172

174-
#define RPC_SIGNALLED(t) test_bit(RPC_TASK_SIGNALLED, &(t)->tk_runstate)
173+
#define RPC_SIGNALLED(t) (READ_ONCE(task->tk_rpc_status) == -ERESTARTSYS)
175174

176175
/*
177176
* Task priorities.

include/trace/events/sunrpc.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,7 @@ TRACE_EVENT(rpc_request,
360360
{ (1UL << RPC_TASK_ACTIVE), "ACTIVE" }, \
361361
{ (1UL << RPC_TASK_NEED_XMIT), "NEED_XMIT" }, \
362362
{ (1UL << RPC_TASK_NEED_RECV), "NEED_RECV" }, \
363-
{ (1UL << RPC_TASK_MSG_PIN_WAIT), "MSG_PIN_WAIT" }, \
364-
{ (1UL << RPC_TASK_SIGNALLED), "SIGNALLED" })
363+
{ (1UL << RPC_TASK_MSG_PIN_WAIT), "MSG_PIN_WAIT" })
365364

366365
DECLARE_EVENT_CLASS(rpc_task_running,
367366

net/sunrpc/sched.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -864,8 +864,6 @@ void rpc_signal_task(struct rpc_task *task)
864864
if (!rpc_task_set_rpc_status(task, -ERESTARTSYS))
865865
return;
866866
trace_rpc_task_signalled(task, task->tk_action);
867-
set_bit(RPC_TASK_SIGNALLED, &task->tk_runstate);
868-
smp_mb__after_atomic();
869867
queue = READ_ONCE(task->tk_waitqueue);
870868
if (queue)
871869
rpc_wake_up_queued_task(queue, task);

0 commit comments

Comments
 (0)