Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Reported-by: kernel test robot <rong.a.chen@intel.com>
Cc: Jan Stancek <jstancek@redhat.com>
Cc: Cyril Hrubis <chrubis@suse.cz>
Link: https://lore.kernel.org/lkml/20200615085836.GR12456@shao2-debian
Fixes: 303cc571d107 ("nsproxy: attach to namespaces via pidfds")
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>

+1 -1
+1 -1
kernel/nsproxy.c
··· 531 531 } else if (!IS_ERR(pidfd_pid(file))) { 532 532 err = check_setns_flags(flags); 533 533 } else { 534 - err = -EBADF; 534 + err = -EINVAL; 535 535 } 536 536 if (err) 537 537 goto out;