* [PATCH] nsfs: fix wrong error code returned for pidns ioctls
@ 2026-05-07 11:14 Zhihao Cheng
2026-05-07 11:29 ` Zhihao Cheng
0 siblings, 1 reply; 2+ messages in thread
From: Zhihao Cheng @ 2026-05-07 11:14 UTC (permalink / raw)
To: trondmy, anna, viro, brauner, jlayton, josef
Cc: linux-nfs, linux-kernel, linux-fsdevel, chengzhihao1, yangerkun,
yi.zhang, changdiankang
When executing NS_GET_PID_FROM_PIDNS (or similar pidns ioctls), if the
target task cannot be found in the corresponding pid_ns, the error code
should be ESRCH instead of ENOTTY.
This bug was introduced when the extensible ioctl handling was added.
Without proper return, ret would be overwritten by the default case in
the extensible ioctl switch statement.
Fixes: a1d220d9dafa8 ("nsfs: iterate through mount namespaces")
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
---
fs/nfs/nfs4state.c | 1 +
fs/nsfs.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 305a772e5497..5044bb4c870f 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -2039,6 +2039,7 @@ static int nfs4_purge_lease(struct nfs_client *clp)
*
* Returns zero or a negative NFS4ERR status code.
*/
+
static int nfs4_try_migration(struct nfs_server *server, const struct cred *cred)
{
struct nfs_client *clp = server->nfs_client;
diff --git a/fs/nsfs.c b/fs/nsfs.c
index 51e8c9430477..160018c4fb36 100644
--- a/fs/nsfs.c
+++ b/fs/nsfs.c
@@ -266,7 +266,7 @@ static long ns_ioctl(struct file *filp, unsigned int ioctl,
else
tsk = find_task_by_pid_ns(arg, pid_ns);
if (!tsk)
- break;
+ return ret;
switch (ioctl) {
case NS_GET_PID_FROM_PIDNS:
--
2.52.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] nsfs: fix wrong error code returned for pidns ioctls
2026-05-07 11:14 [PATCH] nsfs: fix wrong error code returned for pidns ioctls Zhihao Cheng
@ 2026-05-07 11:29 ` Zhihao Cheng
0 siblings, 0 replies; 2+ messages in thread
From: Zhihao Cheng @ 2026-05-07 11:29 UTC (permalink / raw)
To: trondmy, anna, viro, brauner, jlayton, josef
Cc: linux-nfs, linux-kernel, linux-fsdevel, yangerkun, yi.zhang,
changdiankang
在 2026/5/7 19:14, Zhihao Cheng 写道:
> When executing NS_GET_PID_FROM_PIDNS (or similar pidns ioctls), if the
> target task cannot be found in the corresponding pid_ns, the error code
> should be ESRCH instead of ENOTTY.
>
> This bug was introduced when the extensible ioctl handling was added.
> Without proper return, ret would be overwritten by the default case in
> the extensible ioctl switch statement.
>
> Fixes: a1d220d9dafa8 ("nsfs: iterate through mount namespaces")
> Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
> ---
> fs/nfs/nfs4state.c | 1 +
> fs/nsfs.c | 2 +-
> 2 files changed, 2 insertions(+), 1 deletion(-)
Ignore this patch, see v2.
https://lore.kernel.org/linux-fsdevel/20260507112301.1042757-1-chengzhihao1@huawei.com/T/#u>
> diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
> index 305a772e5497..5044bb4c870f 100644
> --- a/fs/nfs/nfs4state.c
> +++ b/fs/nfs/nfs4state.c
> @@ -2039,6 +2039,7 @@ static int nfs4_purge_lease(struct nfs_client *clp)
> *
> * Returns zero or a negative NFS4ERR status code.
> */
> +
> static int nfs4_try_migration(struct nfs_server *server, const struct cred *cred)
> {
> struct nfs_client *clp = server->nfs_client;
> diff --git a/fs/nsfs.c b/fs/nsfs.c
> index 51e8c9430477..160018c4fb36 100644
> --- a/fs/nsfs.c
> +++ b/fs/nsfs.c
> @@ -266,7 +266,7 @@ static long ns_ioctl(struct file *filp, unsigned int ioctl,
> else
> tsk = find_task_by_pid_ns(arg, pid_ns);
> if (!tsk)
> - break;
> + return ret;
>
> switch (ioctl) {
> case NS_GET_PID_FROM_PIDNS:
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-07 11:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-07 11:14 [PATCH] nsfs: fix wrong error code returned for pidns ioctls Zhihao Cheng
2026-05-07 11:29 ` Zhihao Cheng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®