* [PATCH v2] nsfs: fix wrong error code returned for pidns ioctls
@ 2026-05-07 11:23 Zhihao Cheng
2026-05-07 11:29 ` yangerkun
2026-05-11 14:00 ` Christian Brauner
0 siblings, 2 replies; 3+ messages in thread
From: Zhihao Cheng @ 2026-05-07 11:23 UTC (permalink / raw)
To: viro, brauner, jlayton, josef
Cc: linux-fsdevel, linux-kernel, 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>
---
v1->v2: Delete unnecessary blank line.
fs/nsfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] nsfs: fix wrong error code returned for pidns ioctls
2026-05-07 11:23 [PATCH v2] nsfs: fix wrong error code returned for pidns ioctls Zhihao Cheng
@ 2026-05-07 11:29 ` yangerkun
2026-05-11 14:00 ` Christian Brauner
1 sibling, 0 replies; 3+ messages in thread
From: yangerkun @ 2026-05-07 11:29 UTC (permalink / raw)
To: Zhihao Cheng, viro, brauner, jlayton, josef
Cc: linux-fsdevel, linux-kernel, yi.zhang, changdiankang
LGTM
Reviewed-by: Yang Erkun <yangerkun@huawei.com>
在 2026/5/7 19:23, 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>
> ---
> v1->v2: Delete unnecessary blank line.
> fs/nsfs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> 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] 3+ messages in thread
* Re: [PATCH v2] nsfs: fix wrong error code returned for pidns ioctls
2026-05-07 11:23 [PATCH v2] nsfs: fix wrong error code returned for pidns ioctls Zhihao Cheng
2026-05-07 11:29 ` yangerkun
@ 2026-05-11 14:00 ` Christian Brauner
1 sibling, 0 replies; 3+ messages in thread
From: Christian Brauner @ 2026-05-11 14:00 UTC (permalink / raw)
To: Zhihao Cheng, viro, jlayton, josef
Cc: Christian Brauner, linux-fsdevel, linux-kernel, yangerkun,
yi.zhang, changdiankang
On Thu, 07 May 2026 19:23:01 +0800, Zhihao Cheng wrote:
> 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.
>
> [...]
Applied to the vfs.fixes branch of the vfs/vfs.git tree.
Patches in the vfs.fixes branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.fixes
[1/1] nsfs: fix wrong error code returned for pidns ioctls
https://git.kernel.org/vfs/vfs/c/725ecd80688b
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-11 14:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-07 11:23 [PATCH v2] nsfs: fix wrong error code returned for pidns ioctls Zhihao Cheng
2026-05-07 11:29 ` yangerkun
2026-05-11 14:00 ` Christian Brauner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox