Hi all,
Here are the fixes I previously mentioned I would send. I previously
assumed that the tests were mostly run as root, but it turns out
everything else besides the stuff I wrote in the seccomp tests either
sets NNP and doesn't require real root, so it all actually works. This
set of fixes should make most of the other tests work unprivileged,
while XFAIL-ing the one that requires real root.
Cheers,
Tycho
Tycho Andersen (6):
selftests: don't kill child immediately in get_metadata() test
selftests: fix typo in seccomp_bpf.c
selftest: include stdio.h in kselftest.h
selftests: skip seccomp get_metadata test if not real root
selftests: set NO_NEW_PRIVS bit in seccomp user tests
selftests: unshare userns in seccomp pidns testcases
tools/testing/selftests/kselftest.h | 1 +
tools/testing/selftests/seccomp/seccomp_bpf.c | 42 ++++++++++++++++---
2 files changed, 38 insertions(+), 5 deletions(-)
--
2.19.1
Newly added test case bpf test_netcnt failed on i386 and qemu_i386 on
mainline and -next kernel.
Here we are running i386 kernel on x86_64 device.
Pass on x86_64, arm64 and arm.
Am i missing any pre required Kconfigs ?
Test output log,
selftests: bpf: test_netcnt
libbpf: failed to create map (name: 'percpu_netcnt'): Invalid argument
libbpf: failed to load object './netcnt_prog.o'
Failed to load bpf program
not ok 1.. selftests: bpf: test_netcnt [FAIL]
selftests: bpf_test_netcnt [FAIL]
Full test log,
https://lkft.validation.linaro.org/scheduler/job/574652#L2903
Kernel Config,
http://snapshots.linaro.org/openembedded/lkft/rocko/intel-core2-32/lkft/lin…
Test results comparison of arm64, arm, x86_64 and i386 (kernel running
on x86_64 machine).
https://qa-reports.linaro.org/_/comparetest/?project=22&project=6&suite=kse…
Best regards
Naresh Kamboju
With more and more resctrl features are being added by Intel, AMD
and ARM, a test tool is becoming more and more useful to validate
that both hardware and software functionalities work as expected.
We introduce resctrl selftest to cover resctrl features on both
X86 and ARM architectures. It first implements MBM (Memory Bandwidth
Monitoring) and MBA (Memory Bandwidth Allocation) tests. We can enhance
the selftest tool to include more functionality tests in future.
There is an existing resctrl test suite 'intel_cmt_cat'. But the major
purpose of the tool is to test Intel(R) RDT hardware via writing and
reading MSR registers. It does access resctrl file system; but the
functionalities are very limited. And it doesn't support automatic test
and a lot of manual verifications are involved.
So the selftest tool we are introducing here provides a convenient
tool which does automatic resctrl testing, is easily available in kernel
tree, and will be extended to AMD QoS and ARM MPAM.
The selftest tool is in tools/testing/selftests/resctrl in order to have
generic test code for all architectures.
Changelog:
v5:
- Based the v4 patches submitted by Fenghua Yu and added changes to support
AMD.
- Changed the function name get_sock_num to get_resource_id. Intel uses
socket number for schemata and AMD uses l3 index id. To generalize changed
the function name to get_resource_id.
- Added the code to detect vendor.
- Disabled the few tests for AMD where the test results are not clear.
Also AMD does not have IMC.
- Fixed few compile issues.
- Some cleanup to make each patch independent.
- Tested the patches on AMD system. Fenghua, Need your help to test on
Intel box. Please feel free to change and resubmit if something
broken.
- Here is the link for previous version.
https://lore.kernel.org/lkml/1545438038-75107-1-git-send-email-fenghua.yu@i…
v4:
- address comments from Balu and Randy
- Add CAT and CQM tests
v3:
- Change code based on comments from Babu Moger
- Remove some unnessary code and use pipe to communicate b/w processes
v2:
- Change code based on comments from Babu Moger
- Clean up other places.
Arshiya Hayatkhan Pathan (4):
selftests/resctrl: Add MBM test
selftests/resctrl: Add MBA test
selftests/resctrl Add Cache QoS Monitoring (CQM) selftest
selftests/resctrl: Add Cache Allocation Technology (CAT) selftest
Babu Moger (3):
selftests/resctrl: Add vendor detection mechanism
selftests/resctrl: Use cache index3 id for AMD schemata masks
selftests/resctrl: Disable MBA and MBM tests for AMD
Fenghua Yu (2):
selftests/resctrl: Add README for resctrl tests
selftests/resctrl: Add the test in MAINTAINERS
Sai Praneeth Prakhya (4):
selftests/resctrl: Add basic resctrl file system operations and data
selftests/resctrl: Read memory bandwidth from perf IMC counter and
from resctrl file system
selftests/resctrl: Add callback to start a benchmark
selftests/resctrl: Add built in benchmark
MAINTAINERS | 1 +
tools/testing/selftests/resctrl/Makefile | 16 +
tools/testing/selftests/resctrl/README | 53 ++
tools/testing/selftests/resctrl/cache.c | 275 +++++++++
tools/testing/selftests/resctrl/cat_test.c | 243 ++++++++
tools/testing/selftests/resctrl/cqm_test.c | 169 ++++++
tools/testing/selftests/resctrl/fill_buf.c | 198 +++++++
tools/testing/selftests/resctrl/mba_test.c | 174 ++++++
tools/testing/selftests/resctrl/mbm_test.c | 146 +++++
tools/testing/selftests/resctrl/resctrl.h | 117 ++++
tools/testing/selftests/resctrl/resctrl_tests.c | 243 ++++++++
tools/testing/selftests/resctrl/resctrl_val.c | 727 ++++++++++++++++++++++++
tools/testing/selftests/resctrl/resctrlfs.c | 649 +++++++++++++++++++++
13 files changed, 3011 insertions(+)
create mode 100644 tools/testing/selftests/resctrl/Makefile
create mode 100644 tools/testing/selftests/resctrl/README
create mode 100644 tools/testing/selftests/resctrl/cache.c
create mode 100644 tools/testing/selftests/resctrl/cat_test.c
create mode 100644 tools/testing/selftests/resctrl/cqm_test.c
create mode 100644 tools/testing/selftests/resctrl/fill_buf.c
create mode 100644 tools/testing/selftests/resctrl/mba_test.c
create mode 100644 tools/testing/selftests/resctrl/mbm_test.c
create mode 100644 tools/testing/selftests/resctrl/resctrl.h
create mode 100644 tools/testing/selftests/resctrl/resctrl_tests.c
create mode 100644 tools/testing/selftests/resctrl/resctrl_val.c
create mode 100644 tools/testing/selftests/resctrl/resctrlfs.c
--
1.8.3.1
Hi all,
This patch series contains several build fixes and cleanups for issues I
encountered when trying to cross-build an rtctest binary in a separate
output directory (like I use for all my kernel builds).
Most patches are independent. Exceptions are:
- Patch 3 depends on patch 2,
- Patch 7 depends on patch 6,
- Patch 11 depends on patches 2 and 3,
This has been tested with native (amd64):
- make kselftest-build
- make -C tools/testing/selftests
- make O=/tmp/kselftest kselftest-build
- make O=/tmp/kselftest -C tools/testing/selftests
and cross-builds (arm):
- make kselftest-build (from a separate output directory).
Known remaining issues (not introduced by this patch series):
- tools/lib/bpf fails to build in some cases (cfr.
https://lore.kernel.org/lkml/CAMuHMdXRN=mSKTjZNBSxQi-pkgSrKqeANxD-GB+hqC8pD…),
- tools/gpio is not always built correctly,
- When building in a separate output directory, there are still files
created in the source directory under:
- arch/x86/include/generated/,
- arch/x86/tools/,
- include/generated/uapi/linux,
- scripts (fixdep and unifdef),
- Some tests may fail to find the installed header files,
- There may be^H^H^H^H^H^Hare more.
Thanks for your comments!
Geert Uytterhoeven (12):
selftests: gpio-mockup-chardev: Check asprintf() for error
selftests: Fix output directory with O=
selftests: Fix header install directory with O=
selftests: android: ion: Fix ionmap_test dependencies
selftests: seccomp: Fix test dependencies and rules
selftests: lib.mk: Add rule to build object file from C source file
selftests: memfd: Fix build with O=
selftests: timestamping: Remove superfluous rules
selftests: sparc64: Remove superfluous rules
selftests: intel_pstate: Remove unused header dependency rule
selftests: Add kselftest-build target
[RFC] selftests: gpio: Fix building tools/gpio from kselftests
Documentation/dev-tools/kselftest.rst | 4 ++++
Makefile | 9 +++++++--
tools/testing/selftests/android/ion/Makefile | 6 +-----
tools/testing/selftests/gpio/Makefile | 12 +++++++-----
.../testing/selftests/gpio/gpio-mockup-chardev.c | 9 ++++++---
tools/testing/selftests/intel_pstate/Makefile | 2 --
tools/testing/selftests/lib.mk | 4 ++++
tools/testing/selftests/memfd/Makefile | 8 +++-----
.../selftests/networking/timestamping/Makefile | 5 -----
tools/testing/selftests/seccomp/Makefile | 15 +++------------
tools/testing/selftests/sparc64/drivers/Makefile | 4 ----
11 files changed, 35 insertions(+), 43 deletions(-)
--
2.17.1
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert(a)linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Hi Kees and James,
seccomp_bpf test hangs right after the following test passes
with EBUSY. Please see log at the end.
/* Installing a second listener in the chain should EBUSY */
EXPECT_EQ(user_trap_syscall(__NR_getpid,
SECCOMP_FILTER_FLAG_NEW_LISTENER),
-1);
EXPECT_EQ(errno, EBUSY);
The user_notification_basic test starts running I assume and then
the hang.
The only commit I see that could be suspect is the following as
it talks about adding SECCOMP_RET_USER_NOTIF
commit d9a7fa67b4bfe6ce93ee9aab23ae2e7ca0763e84
Merge: f218a29c25ad 55b8cbe470d1
Author: Linus Torvalds <torvalds(a)linux-foundation.org>
Date: Wed Jan 2 09:48:13 2019 -0800
Merge branch 'next-seccomp' of
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security
Pull seccomp updates from James Morris:
- Add SECCOMP_RET_USER_NOTIF
- seccomp fixes for sparse warnings and s390 build (Tycho)
* 'next-seccomp' of
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security:
seccomp, s390: fix build for syscall type change
seccomp: fix poor type promotion
samples: add an example of seccomp user trap
seccomp: add a return code to trap to userspace
seccomp: switch system call argument type to void *
seccomp: hoist struct seccomp_data recalculation higher
Any ideas on how to proceed? Here is the log. The following
reproduces the problem.
make -C tools/testing/selftests/seccomp/ run_tests
seccomp_bpf.c:2947:global.get_metadata:Expected 0 (0) ==
seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FILTER_FLAG_LOG, &prog)
(18446744073709551615)
seccomp_bpf.c:2959:global.get_metadata:Expected 1 (1) == read(pipefd[0],
&buf, 1) (0)
global.get_metadata: Test terminated by assertion
[ FAIL ] global.get_metadata
[ RUN ] global.user_notification_basic
seccomp_bpf.c:3036:global.user_notification_basic:Expected 0 (0) ==
WEXITSTATUS(status) (1)
seccomp_bpf.c:3039:global.user_notification_basic:Expected
seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog) (18446744073709551615) == 0 (0)
seccomp_bpf.c:3040:global.user_notification_basic:Expected
seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog) (18446744073709551615) == 0 (0)
seccomp_bpf.c:3041:global.user_notification_basic:Expected
seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog) (18446744073709551615) == 0 (0)
seccomp_bpf.c:3042:global.user_notification_basic:Expected
seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog) (18446744073709551615) == 0 (0)
seccomp_bpf.c:3047:global.user_notification_basic:Expected listener
(18446744073709551615) >= 0 (0)
seccomp_bpf.c:3053:global.user_notification_basic:Expected errno (13) ==
EBUSY (16)
thanks,
-- Shuah
In the face of missing user notification support, the self test needs
to stop executing a test (ASSERT_*) instead of just reporting and
continuing (EXPECT_*). This adjusts the user notification tests to do
that where needed.
Reported-by: Shuah Khan <shuah(a)kernel.org>
Fixes: 6a21cc50f0c7 ("seccomp: add a return code to trap to userspace")
Signed-off-by: Kees Cook <keescook(a)chromium.org>
---
tools/testing/selftests/seccomp/seccomp_bpf.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
index 067cb4607d6c..496a9a8c773a 100644
--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
@@ -3044,7 +3044,7 @@ TEST(user_notification_basic)
/* Check that the basic notification machinery works */
listener = user_trap_syscall(__NR_getpid,
SECCOMP_FILTER_FLAG_NEW_LISTENER);
- EXPECT_GE(listener, 0);
+ ASSERT_GE(listener, 0);
/* Installing a second listener in the chain should EBUSY */
EXPECT_EQ(user_trap_syscall(__NR_getpid,
@@ -3103,7 +3103,7 @@ TEST(user_notification_kill_in_middle)
listener = user_trap_syscall(__NR_getpid,
SECCOMP_FILTER_FLAG_NEW_LISTENER);
- EXPECT_GE(listener, 0);
+ ASSERT_GE(listener, 0);
/*
* Check that nothing bad happens when we kill the task in the middle
@@ -3152,7 +3152,7 @@ TEST(user_notification_signal)
listener = user_trap_syscall(__NR_gettid,
SECCOMP_FILTER_FLAG_NEW_LISTENER);
- EXPECT_GE(listener, 0);
+ ASSERT_GE(listener, 0);
pid = fork();
ASSERT_GE(pid, 0);
@@ -3215,7 +3215,7 @@ TEST(user_notification_closed_listener)
listener = user_trap_syscall(__NR_getpid,
SECCOMP_FILTER_FLAG_NEW_LISTENER);
- EXPECT_GE(listener, 0);
+ ASSERT_GE(listener, 0);
/*
* Check that we get an ENOSYS when the listener is closed.
@@ -3376,7 +3376,7 @@ TEST(seccomp_get_notif_sizes)
{
struct seccomp_notif_sizes sizes;
- EXPECT_EQ(seccomp(SECCOMP_GET_NOTIF_SIZES, 0, &sizes), 0);
+ ASSERT_EQ(seccomp(SECCOMP_GET_NOTIF_SIZES, 0, &sizes), 0);
EXPECT_EQ(sizes.seccomp_notif, sizeof(struct seccomp_notif));
EXPECT_EQ(sizes.seccomp_notif_resp, sizeof(struct seccomp_notif_resp));
}
--
2.17.1
--
Kees Cook