Skip to contentSkip to conversation

NFS client leaks -ERESTARTSYS into userland

PATCH Jeff Layton 2 participants 2 messages Nov 16

Subsystems (3)
lore
Share & tools
lore

Jeff Layton

author maintainer
#0 lore raw

We had a report internally of ERESTARTSYS leaking into userland after killing a process stuck waiting for a missing NFS server.

I've got a draft patch, but agentic review keeps finding issues with it and I don't have the cycles at the moment to chase this down. I had claude put together a reproducer (attached), which seems to work. I've attached the draft patch too, but it's still a bit rough.

Cheers,

Signature · 1 line
Jeff Layton <[email protected]>

From 1641d4b702d4451f244a8767cb144b06eebadc84 Mon Sep 17 00:00:00 2001
From: Jeff Layton <[email protected]>
Date: Fri, 13 Nov 2026 14:00:15 -0500
Subject: [PATCH] SUNRPC: report -EIO, not -ERESTARTSYS, for administratively
killed tasks

rpc_killall_tasks() terminates every task on an rpc_clnt through rpc_signal_task(), which sets -ERESTARTSYS. That code means "a signal arrived, restart the syscall", and the syscall layer restarts the call only when a signal is actually pending. Its one caller, nfs_umount_begin(), is not a signal: it runs on a forced unmount (umount -f). There is no signal to restart on, so -ERESTARTSYS is returned to userspace as error 512.

Seen in production: a forced unmount of an NFS filesystem made mkdir(2) fail with "Unknown error 512" in an unrelated process. Note that nfs_umount_begin() aborts calls per superblock, so one container's forced unmount hits every process using that filesystem on the host.

nfs_umount_begin()'s own comment already says what should happen:

	/* -EIO all pending I/O */

Make the code match. Split the status out of rpc_signal_task() and add rpc_abort_task(), which reports -EIO, and use it in rpc_killall_tasks(). Tasks interrupted by a real signal are unchanged.

---
 include/linux/sunrpc/sched.h |  1 +
 net/sunrpc/clnt.c            |  2 +-
 net/sunrpc/sched.c           | 23 +++++++++++++++++++++--
 3 files changed, 23 insertions(+), 3 deletions(-)
include/linux/sunrpc/sched.h +1 -0
index 0dbdf3722537..79a08171c4b8 100644
@@ -222,6 +222,7 @@ void		rpc_put_task_async(struct rpc_task *);
 bool		rpc_task_set_rpc_status(struct rpc_task *task, int rpc_status);
 void		rpc_task_try_cancel(struct rpc_task *task, int error);
 void		rpc_signal_task(struct rpc_task *);
+void		rpc_abort_task(struct rpc_task *);
 void		rpc_exit_task(struct rpc_task *);
 void		rpc_exit(struct rpc_task *, int);
 void		rpc_release_calldata(const struct rpc_call_ops *, void *);
net/sunrpc/clnt.c +1 -1
index 6cedc824cf82..9055f0299836 100644
@@ -896,7 +896,7 @@ void rpc_killall_tasks(struct rpc_clnt *clnt)
 	trace_rpc_clnt_killall(clnt);
 	spin_lock(&clnt->cl_lock);
 	list_for_each_entry(rovr, &clnt->cl_tasks, tk_task)
-		rpc_signal_task(rovr);
+		rpc_abort_task(rovr);
 	spin_unlock(&clnt->cl_lock);
 }
 EXPORT_SYMBOL_GPL(rpc_killall_tasks);
net/sunrpc/sched.c +21 -2
index 016f16ca5779..663d8e157f9a 100644
@@ -854,14 +854,14 @@ void rpc_exit_task(struct rpc_task *task)
 	}
 }
 
-void rpc_signal_task(struct rpc_task *task)
+static void rpc_signal_task_status(struct rpc_task *task, int status)
 {
 	struct rpc_wait_queue *queue;
 
 	if (!RPC_IS_ACTIVATED(task))
 		return;
 
-	if (!rpc_task_set_rpc_status(task, -ERESTARTSYS))
+	if (!rpc_task_set_rpc_status(task, status))
 		return;
 	trace_rpc_task_signalled(task, task->tk_action);
 	queue = READ_ONCE(task->tk_waitqueue);
@@ -869,6 +869,25 @@ void rpc_signal_task(struct rpc_task *task)
 		rpc_wake_up_queued_task(queue, task);
 }
 
+void rpc_signal_task(struct rpc_task *task)
+{
+	rpc_signal_task_status(task, -ERESTARTSYS);
+}
+
+/**
+ * rpc_abort_task - terminate a task on behalf of an administrative action
+ * @task: the task to terminate
+ *
+ * Unlike rpc_signal_task(), which reports -ERESTARTSYS for a task
+ * interrupted by a signal, this reports -EIO: there is no signal for
+ * the syscall layer to restart on, so -ERESTARTSYS would be returned
+ * to userspace as error 512.
+ */
+void rpc_abort_task(struct rpc_task *task)
+{
+	rpc_signal_task_status(task, -EIO);
+}
+
 void rpc_task_try_cancel(struct rpc_task *task, int error)
 {
 	struct rpc_wait_queue *queue;
Signature · 1 line
2.56.1
#1 lore raw

Hi Jeff,

I am pretty sure this is an artifact of my changes.

https://lore.kernel.org/linux-nfs/[email protected]/

I will follow up.

Best regards,
Tigran

Quoted 9 lines · Jeff Layton

We had a report internally of ERESTARTSYS leaking into userland after killing a process stuck waiting for a missing NFS server.

I've got a draft patch, but agentic review keeps finding issues with it and I don't have the cycles at the moment to chase this down. I had claude put together a reproducer (attached), which seems to work. I've attached the draft patch too, but it's still a bit rough.

Cheers,