All of lore.kernel.org
 help / color / mirror / Atom feed
* NFS client leaks -ERESTARTSYS into userland
@ 2026-11-16 22:14 Jeff Layton
  2026-11-16 22:41 ` Tigran Mkrtchyan
  0 siblings, 1 reply; 2+ messages in thread
From: Jeff Layton @ 2026-11-16 22:14 UTC (permalink / raw)
  To: Trond Myklebust, Anna Schumaker; +Cc: linux-nfs

[-- Attachment #1: Type: text/plain, Size: 455 bytes --]

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,
-- 
Jeff Layton <jlayton@kernel.org>

[-- Attachment #2: nfs-umount-f-512.sh --]
[-- Type: application/x-shellscript, Size: 4938 bytes --]

[-- Attachment #3: 0001-SUNRPC-report-EIO-not-ERESTARTSYS-for-administrative.patch --]
[-- Type: text/x-patch, Size: 3922 bytes --]

From 1641d4b702d4451f244a8767cb144b06eebadc84 Mon Sep 17 00:00:00 2001
From: Jeff Layton <jlayton@kernel.org>
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.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 include/linux/sunrpc/sched.h |  1 +
 net/sunrpc/clnt.c            |  2 +-
 net/sunrpc/sched.c           | 23 +++++++++++++++++++++--
 3 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h
index 0dbdf3722537..79a08171c4b8 100644
--- a/include/linux/sunrpc/sched.h
+++ b/include/linux/sunrpc/sched.h
@@ -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 *);
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 6cedc824cf82..9055f0299836 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -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);
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index 016f16ca5779..663d8e157f9a 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -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;
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: NFS client leaks -ERESTARTSYS into userland
  2026-11-16 22:14 NFS client leaks -ERESTARTSYS into userland Jeff Layton
@ 2026-11-16 22:41 ` Tigran Mkrtchyan
  0 siblings, 0 replies; 2+ messages in thread
From: Tigran Mkrtchyan @ 2026-11-16 22:41 UTC (permalink / raw)
  To: linux-nfs, Jeff Layton, Trond Myklebust, Anna Schumaker

Hi Jeff,

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

https://lore.kernel.org/linux-nfs/707767179.31268962.1760982877695.JavaMail.zimbra@desy.de/

I will follow up.

Best regards,
  Tigran 

On November 16, 2026 11:14:55 PM GMT+01:00, Jeff Layton <jlayton@kernel.org> wrote:
>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,

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-16 22:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-16 22:14 NFS client leaks -ERESTARTSYS into userland Jeff Layton
2026-11-16 22:41 ` Tigran Mkrtchyan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.