2019-07-29 12:59:34

by Chen, Rong A

[permalink] [raw]
Subject: [ptrace] 201766a20e: kernel_selftests.seccomp.make_fail

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

commit: 201766a20e30f982ccfe36bebfad9602c3ff574a ("ptrace: add PTRACE_GET_SYSCALL_INFO request")
https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux.git master

in testcase: kernel_selftests
with following parameters:

group: kselftests-02

test-description: The kernel contains a set of "self tests" under the tools/testing/selftests/ directory. These are intended to be small unit tests to exercise individual code paths in the kernel.
test-url: https://www.kernel.org/doc/Documentation/kselftest.txt


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

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]>



2019-07-26 16:52:03 make run_tests -C seccomp
make: Entering directory '/usr/src/perf_selftests-x86_64-rhel-7.6-201766a20e30f982ccfe36bebfad9602c3ff574a/tools/testing/selftests/seccomp'
gcc -Wl,-no-as-needed -Wall seccomp_bpf.c -lpthread -o seccomp_bpf
In file included from seccomp_bpf.c:51:0:
seccomp_bpf.c: In function ‘tracer_ptrace’:
seccomp_bpf.c:1787:20: error: ‘PTRACE_EVENTMSG_SYSCALL_ENTRY’ undeclared (first use in this function)
EXPECT_EQ(entry ? PTRACE_EVENTMSG_SYSCALL_ENTRY
^
../kselftest_harness.h:608:13: note: in definition of macro ‘__EXPECT’
__typeof__(_expected) __exp = (_expected); \
^~~~~~~~~
seccomp_bpf.c:1787:2: note: in expansion of macro ‘EXPECT_EQ’
EXPECT_EQ(entry ? PTRACE_EVENTMSG_SYSCALL_ENTRY
^~~~~~~~~
seccomp_bpf.c:1787:20: note: each undeclared identifier is reported only once for each function it appears in
EXPECT_EQ(entry ? PTRACE_EVENTMSG_SYSCALL_ENTRY
^
../kselftest_harness.h:608:13: note: in definition of macro ‘__EXPECT’
__typeof__(_expected) __exp = (_expected); \
^~~~~~~~~
seccomp_bpf.c:1787:2: note: in expansion of macro ‘EXPECT_EQ’
EXPECT_EQ(entry ? PTRACE_EVENTMSG_SYSCALL_ENTRY
^~~~~~~~~
seccomp_bpf.c:1788:6: error: ‘PTRACE_EVENTMSG_SYSCALL_EXIT’ undeclared (first use in this function)
: PTRACE_EVENTMSG_SYSCALL_EXIT, msg);
^
../kselftest_harness.h:608:13: note: in definition of macro ‘__EXPECT’
__typeof__(_expected) __exp = (_expected); \
^~~~~~~~~
seccomp_bpf.c:1787:2: note: in expansion of macro ‘EXPECT_EQ’
EXPECT_EQ(entry ? PTRACE_EVENTMSG_SYSCALL_ENTRY
^~~~~~~~~
Makefile:12: recipe for target 'seccomp_bpf' failed
make: *** [seccomp_bpf] Error 1
make: Leaving directory '/usr/src/perf_selftests-x86_64-rhel-7.6-201766a20e30f982ccfe36bebfad9602c3ff574a/tools/testing/selftests/seccomp'


To reproduce:

# build kernel
cd linux
cp config-5.2.0-10889-g201766a20e30f9 .config
make HOSTCC=gcc-7 CC=gcc-7 ARCH=x86_64 olddefconfig prepare modules_prepare bzImage

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



Thanks,
Rong Chen


Attachments:
(No filename) (3.12 kB)
config-5.2.0-10889-g201766a20e30f9 (202.60 kB)
job-script (6.51 kB)
dmesg.xz (63.74 kB)
kernel_selftests (167.94 kB)
Download all attachments

2019-08-05 09:48:36

by Dmitry V. Levin

[permalink] [raw]
Subject: Re: [ptrace] 201766a20e: kernel_selftests.seccomp.make_fail

On Mon, Jul 29, 2019 at 05:35:30PM +0800, kernel test robot wrote:
> FYI, we noticed the following commit (built with gcc-7):
>
> commit: 201766a20e30f982ccfe36bebfad9602c3ff574a ("ptrace: add PTRACE_GET_SYSCALL_INFO request")
> https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux.git master
>
> in testcase: kernel_selftests
> with following parameters:
>
> group: kselftests-02
>
> test-description: The kernel contains a set of "self tests" under the tools/testing/selftests/ directory. These are intended to be small unit tests to exercise individual code paths in the kernel.
> test-url: https://www.kernel.org/doc/Documentation/kselftest.txt

The URL above also says: "Tests are intended to be run after building,
installing and booting a kernel".

Please build selftests with installed kernel headers corresponding to the
installed kernel.

Alternatively, tools/testing/selftests/lib.mk could be extended
to include uapi headers from the kernel tree into CPPFLAGS, e.g.

diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 1c8a1963d03f..b5f4f0fb8eeb 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -10,6 +10,9 @@ ifeq (0,$(MAKELEVEL))
endif
selfdir = $(realpath $(dir $(filter %/lib.mk,$(MAKEFILE_LIST))))

+uapi_dir = $(realpath $(selfdir)/../../../include/uapi)
+CPPFLAGS += -I$(uapi_dir)
+
# The following are built by lib.mk common compile rules.
# TEST_CUSTOM_PROGS should be used by tests that require
# custom build rule and prevent common build rule use.


--
ldv


Attachments:
(No filename) (1.58 kB)
signature.asc (817.00 B)
Download all attachments

2019-08-28 17:39:11

by Kees Cook

[permalink] [raw]
Subject: Re: [ptrace] 201766a20e: kernel_selftests.seccomp.make_fail

On Mon, Aug 05, 2019 at 12:47:19PM +0300, Dmitry V. Levin wrote:
> On Mon, Jul 29, 2019 at 05:35:30PM +0800, kernel test robot wrote:
> > FYI, we noticed the following commit (built with gcc-7):
> >
> > commit: 201766a20e30f982ccfe36bebfad9602c3ff574a ("ptrace: add PTRACE_GET_SYSCALL_INFO request")
> > https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux.git master
> >
> > in testcase: kernel_selftests
> > with following parameters:
> >
> > group: kselftests-02
> >
> > test-description: The kernel contains a set of "self tests" under the tools/testing/selftests/ directory. These are intended to be small unit tests to exercise individual code paths in the kernel.
> > test-url: https://www.kernel.org/doc/Documentation/kselftest.txt
>
> The URL above also says: "Tests are intended to be run after building,
> installing and booting a kernel".
>
> Please build selftests with installed kernel headers corresponding to the
> installed kernel.
>
> Alternatively, tools/testing/selftests/lib.mk could be extended
> to include uapi headers from the kernel tree into CPPFLAGS, e.g.
>
> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
> index 1c8a1963d03f..b5f4f0fb8eeb 100644
> --- a/tools/testing/selftests/lib.mk
> +++ b/tools/testing/selftests/lib.mk
> @@ -10,6 +10,9 @@ ifeq (0,$(MAKELEVEL))
> endif
> selfdir = $(realpath $(dir $(filter %/lib.mk,$(MAKEFILE_LIST))))
>
> +uapi_dir = $(realpath $(selfdir)/../../../include/uapi)
> +CPPFLAGS += -I$(uapi_dir)
> +
> # The following are built by lib.mk common compile rules.
> # TEST_CUSTOM_PROGS should be used by tests that require
> # custom build rule and prevent common build rule use.

I like this solution, as it's a common problem and it solves it in one
place for all of the selftests.

Reviewed-by: Kees Cook <[email protected]>

--
Kees Cook

2020-09-08 23:33:27

by Kees Cook

[permalink] [raw]
Subject: Re: [ptrace] 201766a20e: kernel_selftests.seccomp.make_fail

On Mon, Aug 05, 2019 at 12:47:19PM +0300, Dmitry V. Levin wrote:
> On Mon, Jul 29, 2019 at 05:35:30PM +0800, kernel test robot wrote:
> > FYI, we noticed the following commit (built with gcc-7):
> >
> > commit: 201766a20e30f982ccfe36bebfad9602c3ff574a ("ptrace: add PTRACE_GET_SYSCALL_INFO request")
> > https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux.git master
> >
> > in testcase: kernel_selftests
> > with following parameters:
> >
> > group: kselftests-02
> >
> > test-description: The kernel contains a set of "self tests" under the tools/testing/selftests/ directory. These are intended to be small unit tests to exercise individual code paths in the kernel.
> > test-url: https://www.kernel.org/doc/Documentation/kselftest.txt
>
> The URL above also says: "Tests are intended to be run after building,
> installing and booting a kernel".
>
> Please build selftests with installed kernel headers corresponding to the
> installed kernel.
>
> Alternatively, tools/testing/selftests/lib.mk could be extended
> to include uapi headers from the kernel tree into CPPFLAGS, e.g.
>
> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
> index 1c8a1963d03f..b5f4f0fb8eeb 100644
> --- a/tools/testing/selftests/lib.mk
> +++ b/tools/testing/selftests/lib.mk
> @@ -10,6 +10,9 @@ ifeq (0,$(MAKELEVEL))
> endif
> selfdir = $(realpath $(dir $(filter %/lib.mk,$(MAKEFILE_LIST))))
>
> +uapi_dir = $(realpath $(selfdir)/../../../include/uapi)
> +CPPFLAGS += -I$(uapi_dir)
> +
> # The following are built by lib.mk common compile rules.
> # TEST_CUSTOM_PROGS should be used by tests that require
> # custom build rule and prevent common build rule use.

*thread necromancy*

I think this is fixed in the selftest tree itself now (though
differently), in that it depends on having build the headers first.

Anyway, please let me know if this is still a problem, and I'll take
another look (and hopefully I also won't lose the thread for a year...)

Thanks!

--
Kees Cook