2020-06-15 09:12:29

by Chen, Rong A

[permalink] [raw]
Subject: 303cc571d1: ltp.setns01.fail

Greeting,

FYI, we noticed the following commit (built with gcc-9):

commit: 303cc571d107b3641d6487061b748e70ffe15ce4 (" iHUEABYKAB0WIQRAhzRXHqcMeLMyaSiRxhvAZXjcogUCXrvAwgAKCRCRxhvAZXjc")
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git master

in testcase: ltp
with following parameters:

disk: 1HDD
fs: btrfs
test: syscalls_part5

test-description: The LTP testsuite contains a collection of tools for testing the Linux kernel and related features.
test-url: http://linux-test-project.github.io/


on test machine: qemu-system-x86_64 -enable-kvm -cpu SandyBridge -smp 2 -m 16G

caused below changes (please refer to attached dmesg/kmsg for entire log/backtrace):




If you fix the issue, kindly add following tag
Reported-by: kernel test robot <[email protected]>




<<<test_start>>>
tag=setns01 stime=1592200758
cmdline="setns01"
contacts=""
analysis=exit
<<<test_output>>>
setns01 0 TINFO : ns_name=ipc, ns_fds[0]=7, ns_types[0]=0x8000000
setns01 0 TINFO : ns_name=mnt, ns_fds[1]=8, ns_types[1]=0x20000
setns01 0 TINFO : ns_name=net, ns_fds[2]=9, ns_types[2]=0x40000000
setns01 0 TINFO : ns_name=pid, ns_fds[3]=10, ns_types[3]=0x20000000
setns01 0 TINFO : ns_name=uts, ns_fds[4]=11, ns_types[4]=0x4000000
setns01 0 TINFO : setns(-1, 0x8000000)
setns01 1 TPASS : invalid fd exp_errno=9
setns01 0 TINFO : setns(-1, 0x20000)
setns01 2 TPASS : invalid fd exp_errno=9
setns01 0 TINFO : setns(-1, 0x40000000)
setns01 3 TPASS : invalid fd exp_errno=9
setns01 0 TINFO : setns(-1, 0x20000000)
setns01 4 TPASS : invalid fd exp_errno=9
setns01 0 TINFO : setns(-1, 0x4000000)
setns01 5 TPASS : invalid fd exp_errno=9
setns01 0 TINFO : setns(12, 0x8000000)
setns01 6 TFAIL : setns01.c:176: regular file fd exp_errno=22: errno=EBADF(9): Bad file descriptor
setns01 0 TINFO : setns(12, 0x20000)
setns01 7 TFAIL : setns01.c:176: regular file fd exp_errno=22: errno=EBADF(9): Bad file descriptor
setns01 0 TINFO : setns(12, 0x40000000)
setns01 8 TFAIL : setns01.c:176: regular file fd exp_errno=22: errno=EBADF(9): Bad file descriptor
setns01 0 TINFO : setns(12, 0x20000000)
setns01 9 TFAIL : setns01.c:176: regular file fd exp_errno=22: errno=EBADF(9): Bad file descriptor
setns01 0 TINFO : setns(12, 0x4000000)
setns01 10 TFAIL : setns01.c:176: regular file fd exp_errno=22: errno=EBADF(9): Bad file descriptor
setns01 0 TINFO : setns(7, 0xffffffff)
setns01 11 TPASS : invalid ns_type exp_errno=22
setns01 0 TINFO : setns(8, 0xffffffff)
setns01 12 TPASS : invalid ns_type exp_errno=22
setns01 0 TINFO : setns(9, 0xffffffff)
setns01 13 TPASS : invalid ns_type exp_errno=22
setns01 0 TINFO : setns(10, 0xffffffff)
setns01 14 TPASS : invalid ns_type exp_errno=22
setns01 0 TINFO : setns(11, 0xffffffff)
setns01 15 TPASS : invalid ns_type exp_errno=22
setns01 0 TINFO : setns(7, 0x20000)
setns01 16 TPASS : mismatch ns_type/fd exp_errno=22
setns01 0 TINFO : setns(8, 0x40000000)
setns01 17 TPASS : mismatch ns_type/fd exp_errno=22
setns01 0 TINFO : setns(9, 0x20000000)
setns01 18 TPASS : mismatch ns_type/fd exp_errno=22
setns01 0 TINFO : setns(10, 0x4000000)
setns01 19 TPASS : mismatch ns_type/fd exp_errno=22
setns01 0 TINFO : setns(11, 0x8000000)
setns01 20 TPASS : mismatch ns_type/fd exp_errno=22
setns01 0 TINFO : setns(7, 0x8000000)
setns01 21 TPASS : without CAP_SYS_ADMIN exp_errno=1
setns01 0 TINFO : setns(8, 0x20000)
setns01 22 TPASS : without CAP_SYS_ADMIN exp_errno=1
setns01 0 TINFO : setns(9, 0x40000000)
setns01 23 TPASS : without CAP_SYS_ADMIN exp_errno=1
setns01 0 TINFO : setns(10, 0x20000000)
setns01 24 TPASS : without CAP_SYS_ADMIN exp_errno=1
setns01 0 TINFO : setns(11, 0x4000000)
setns01 25 TPASS : without CAP_SYS_ADMIN exp_errno=1
<<<execution_status>>>
initiation_status="ok"
duration=0 termination_type=exited termination_id=1 corefile=no
cutime=0 cstime=1
<<<test_end>>>

LTP Version: 20200515-23-gec1b91c46

###############################################################

Done executing testcases.
LTP Version: 20200515-23-gec1b91c46
###############################################################




To reproduce:

# build kernel
cd linux
cp config-5.7.0-rc4-00002-g303cc571d107b .config
make HOSTCC=gcc-9 CC=gcc-9 ARCH=x86_64 olddefconfig prepare modules_prepare bzImage modules
make HOSTCC=gcc-9 CC=gcc-9 ARCH=x86_64 INSTALL_MOD_PATH=<mod-install-dir> modules_install
cd <mod-install-dir>
find lib/ | cpio -o -H newc --quiet | gzip > modules.cgz


git clone https://github.com/intel/lkp-tests.git
cd lkp-tests
bin/lkp qemu -k <bzImage> -m modules.cgz job-script # job-script is attached in this email



Thanks,
Rong Chen


Attachments:
(No filename) (5.03 kB)
config-5.7.0-rc4-00002-g303cc571d107b (205.89 kB)
job-script (5.21 kB)
dmesg.xz (75.95 kB)
ltp (218.98 kB)
Download all attachments

2020-06-15 09:21:41

by Cyril Hrubis

[permalink] [raw]
Subject: Re: [LTP] 303cc571d1: ltp.setns01.fail

Hi!
> setns01 6 TFAIL : setns01.c:176: regular file fd exp_errno=22: errno=EBADF(9): Bad file descriptor
> setns01 0 TINFO : setns(12, 0x20000)
> setns01 7 TFAIL : setns01.c:176: regular file fd exp_errno=22: errno=EBADF(9): Bad file descriptor
> setns01 0 TINFO : setns(12, 0x40000000)
> setns01 8 TFAIL : setns01.c:176: regular file fd exp_errno=22: errno=EBADF(9): Bad file descriptor
> setns01 0 TINFO : setns(12, 0x20000000)
> setns01 9 TFAIL : setns01.c:176: regular file fd exp_errno=22: errno=EBADF(9): Bad file descriptor
> setns01 0 TINFO : setns(12, 0x4000000)
> setns01 10 TFAIL : setns01.c:176: regular file fd exp_errno=22: errno=EBADF(9): Bad file descriptor

The messages here are a bit cryptic, I will fix that later on, but what
it means here is that the errno has changed from EINVAL to EBADF in a
case we pass file descriptor to a regular file to setns().

--
Cyril Hrubis
[email protected]

2020-06-15 14:06:43

by Jan Stancek

[permalink] [raw]
Subject: Re: [LTP] 303cc571d1: ltp.setns01.fail



----- Original Message -----
> Hi!
> > setns01 6 TFAIL : setns01.c:176: regular file fd exp_errno=22:
> > errno=EBADF(9): Bad file descriptor
> > setns01 0 TINFO : setns(12, 0x20000)
> > setns01 7 TFAIL : setns01.c:176: regular file fd exp_errno=22:
> > errno=EBADF(9): Bad file descriptor
> > setns01 0 TINFO : setns(12, 0x40000000)
> > setns01 8 TFAIL : setns01.c:176: regular file fd exp_errno=22:
> > errno=EBADF(9): Bad file descriptor
> > setns01 0 TINFO : setns(12, 0x20000000)
> > setns01 9 TFAIL : setns01.c:176: regular file fd exp_errno=22:
> > errno=EBADF(9): Bad file descriptor
> > setns01 0 TINFO : setns(12, 0x4000000)
> > setns01 10 TFAIL : setns01.c:176: regular file fd exp_errno=22:
> > errno=EBADF(9): Bad file descriptor
>
> The messages here are a bit cryptic, I will fix that later on, but what
> it means here is that the errno has changed from EINVAL to EBADF in a
> case we pass file descriptor to a regular file to setns().

I posted a series that accepts both errnos about week ago:
https://lists.linux.it/pipermail/ltp/2020-June/017467.html

2020-06-15 21:43:05

by Christian Brauner

[permalink] [raw]
Subject: Re: [LTP] 303cc571d1: ltp.setns01.fail

On Mon, Jun 15, 2020 at 10:03:01AM -0400, Jan Stancek wrote:
>
>
> ----- Original Message -----
> > Hi!
> > > setns01 6 TFAIL : setns01.c:176: regular file fd exp_errno=22:
> > > errno=EBADF(9): Bad file descriptor
> > > setns01 0 TINFO : setns(12, 0x20000)
> > > setns01 7 TFAIL : setns01.c:176: regular file fd exp_errno=22:
> > > errno=EBADF(9): Bad file descriptor
> > > setns01 0 TINFO : setns(12, 0x40000000)
> > > setns01 8 TFAIL : setns01.c:176: regular file fd exp_errno=22:
> > > errno=EBADF(9): Bad file descriptor
> > > setns01 0 TINFO : setns(12, 0x20000000)
> > > setns01 9 TFAIL : setns01.c:176: regular file fd exp_errno=22:
> > > errno=EBADF(9): Bad file descriptor
> > > setns01 0 TINFO : setns(12, 0x4000000)
> > > setns01 10 TFAIL : setns01.c:176: regular file fd exp_errno=22:
> > > errno=EBADF(9): Bad file descriptor
> >
> > The messages here are a bit cryptic, I will fix that later on, but what
> > it means here is that the errno has changed from EINVAL to EBADF in a
> > case we pass file descriptor to a regular file to setns().
>
> I posted a series that accepts both errnos about week ago:
> https://lists.linux.it/pipermail/ltp/2020-June/017467.html

When you used to pass an fd that referred to an open file but the file
was not a nsfd the kernel would report EINVAL. Since the pidfd support
this now reports EBADF. While that is a user visible change it is not a
particular worrying one but something we should still fix. Here's the
patch that fixes this:

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;

I'll send a pr for this to Linus this week (or next since I'm on
vacation this week) and get this fixed. Thanks for spotting this. What's
the Reported-by: line format that LTP uses?

Christian

2020-06-16 08:11:31

by Jan Stancek

[permalink] [raw]
Subject: Re: [LTP] 303cc571d1: ltp.setns01.fail



----- Original Message -----
> I'll send a pr for this to Linus this week (or next since I'm on
> vacation this week) and get this fixed. Thanks for spotting this. What's
> the Reported-by: line format that LTP uses?

I'm not sure we ever used one, it's usually various CI systems that
reference LTP. This thread has been started by kernel test robot:
Reported-by: kernel test robot <[email protected]>