]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
nsfs: fix wrong error code returned for pidns ioctls
authorZhihao Cheng <chengzhihao1@huawei.com>
Thu, 7 May 2026 11:23:01 +0000 (19:23 +0800)
committerChristian Brauner <brauner@kernel.org>
Mon, 11 May 2026 13:59:14 +0000 (15:59 +0200)
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>
Link: https://patch.msgid.link/20260507112301.1042757-1-chengzhihao1@huawei.com
Reviewed-by: Yang Erkun <yangerkun@huawei.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/nsfs.c

index 51e8c9430477b6d6346327135c88a85612b7e7e1..160018c4fb362c146116fe485899f5f175e66ee5 100644 (file)
--- 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: