From 6663a9e9de4cda731c12ff7114ef0df2303d6210 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Wed, 17 Jun 2020 00:56:11 +0200 Subject: [PATCH] FROMLIST: nsproxy: restore EINVAL for non-namespace file descriptor The LTP testsuite reported a regression where users would now see EBADF returned instead of EINVAL when an fd was passed that referred to an open file but the file was not a nsfd. Fix this by continuing to report EINVAL. Bug: 159609060 Link: https://lore.kernel.org/lkml/20200615085836.GR12456@shao2-debian Fixes: 303cc571d107 ("nsproxy: attach to namespaces via pidfds") Cc: Jan Stancek Cc: Cyril Hrubis Reported-by: kernel test robot Signed-off-by: Christian Brauner Link: https://lore.kernel.org/lkml/20200616225612.4068799-1-christian.brauner@ubuntu.com/ Signed-off-by: Greg Kroah-Hartman Change-Id: I659d41efb883f641b8db06f2c3b1f0dae8bab064 --- kernel/nsproxy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c index b03df67621d0..cd356630a311 100644 --- a/kernel/nsproxy.c +++ b/kernel/nsproxy.c @@ -531,7 +531,7 @@ SYSCALL_DEFINE2(setns, int, fd, int, flags) } else if (!IS_ERR(pidfd_pid(file))) { err = check_setns_flags(flags); } else { - err = -EBADF; + err = -EINVAL; } if (err) goto out;