summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Coddington <bcodding@redhat.com>2023-03-04 00:08:32 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-03-17 10:45:12 +0300
commitce7dd61e004002bc1c48d1ca47c887f3f3cc7370 (patch)
treee890825fd83b908cd1c797355ee1cfa84a69e6ba
parente1b8342a85289d0d3411744c4fc1e0fc46fc9d5c (diff)
downloadlinux-ce7dd61e004002bc1c48d1ca47c887f3f3cc7370.tar.xz
SUNRPC: Fix a server shutdown leak
[ Upstream commit 9ca6705d9d609441d34f8b853e1e4a6369b3b171 ] Fix a race where kthread_stop() may prevent the threadfn from ever getting called. If that happens the svc_rqst will not be cleaned up. Fixes: ed6473ddc704 ("NFSv4: Fix callback server shutdown") Signed-off-by: Benjamin Coddington <bcodding@redhat.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--net/sunrpc/svc.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index d38788cd9433..af657a482ad2 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -800,6 +800,7 @@ EXPORT_SYMBOL_GPL(svc_set_num_threads);
static int
svc_stop_kthreads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
{
+ struct svc_rqst *rqstp;
struct task_struct *task;
unsigned int state = serv->sv_nrthreads-1;
@@ -808,7 +809,10 @@ svc_stop_kthreads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
task = choose_victim(serv, pool, &state);
if (task == NULL)
break;
- kthread_stop(task);
+ rqstp = kthread_data(task);
+ /* Did we lose a race to svo_function threadfn? */
+ if (kthread_stop(task) == -EINTR)
+ svc_exit_thread(rqstp);
nrservs++;
} while (nrservs < 0);
return 0;