Unverified Commit 725ecd80 authored by Zhihao Cheng's avatar Zhihao Cheng Committed by Christian Brauner
Browse files

nsfs: fix wrong error code returned for pidns ioctls



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: a1d220d9 ("nsfs: iterate through mount namespaces")
Signed-off-by: default avatarZhihao Cheng <chengzhihao1@huawei.com>
Link: https://patch.msgid.link/20260507112301.1042757-1-chengzhihao1@huawei.com


Reviewed-by: default avatarYang Erkun <yangerkun@huawei.com>
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent 834e98ac
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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: