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
An expansion field was added to the kernel copy of this structure for
future use. See mm/gup_benchmark.c.
Add the same expansion field here, so that the IOCTL command decodes
correctly. Otherwise, it fails with EINVAL.
Signed-off-by: Alison Schofield <alison.schofield(a)intel.com>
---
tools/testing/selftests/vm/gup_benchmark.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/testing/selftests/vm/gup_benchmark.c b/tools/testing/selftests/vm/gup_benchmark.c
index 880b96fc80d4..c0534e298b51 100644
--- a/tools/testing/selftests/vm/gup_benchmark.c
+++ b/tools/testing/selftests/vm/gup_benchmark.c
@@ -25,6 +25,7 @@ struct gup_benchmark {
__u64 size;
__u32 nr_pages_per_call;
__u32 flags;
+ __u64 expansion[10]; /* For future use */
};
int main(int argc, char **argv)
--
2.14.1
From: "Joel Fernandes (Google)" <joel(a)joelfernandes.org>
This is just a resend of the previous series at
https://lore.kernel.org/patchwork/patch/1014892/
with a small if block refactor as Andy suggested:
https://lore.kernel.org/patchwork/comment/1198679/
All,
Could you please provide your Reviewed-by / Acked-by tags?
I will also resend the manpage changes shortly.
Joel Fernandes (Google) (2):
mm/memfd: Add an F_SEAL_FUTURE_WRITE seal to memfd
selftests/memfd: Add tests for F_SEAL_FUTURE_WRITE seal
fs/hugetlbfs/inode.c | 2 +-
include/uapi/linux/fcntl.h | 1 +
mm/memfd.c | 3 +-
mm/shmem.c | 25 +++++++-
tools/testing/selftests/memfd/memfd_test.c | 74 ++++++++++++++++++++++
5 files changed, 100 insertions(+), 5 deletions(-)
--
2.20.1.97.g81188d93c3-goog
Fix a call to userspace_mem_region_find to conform to its spec of
taking an inclusive, inclusive range. It was previously being called
with an inclusive, exclusive range. Also remove a redundant region bounds
check in vm_userspace_mem_region_add. Region overlap checking is already
performed by the call to userspace_mem_region_find.
Tested: Compiled tools/testing/selftests/kvm with -static
Ran all resulting test binaries on an Intel Haswell test machine
All tests passed
Signed-off-by: Ben Gardon <bgardon(a)google.com>
Reviewed-by: Jim Mattson <jmattson(a)google.com>
---
tools/testing/selftests/kvm/lib/kvm_util.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
index 23022e9d32eb81..461e1a50779762 100644
--- a/tools/testing/selftests/kvm/lib/kvm_util.c
+++ b/tools/testing/selftests/kvm/lib/kvm_util.c
@@ -571,7 +571,7 @@ void vm_userspace_mem_region_add(struct kvm_vm *vm,
* already exist.
*/
region = (struct userspace_mem_region *) userspace_mem_region_find(
- vm, guest_paddr, guest_paddr + npages * vm->page_size);
+ vm, guest_paddr, (guest_paddr + npages * vm->page_size) + 1);
if (region != NULL)
TEST_ASSERT(false, "overlapping userspace_mem_region already "
"exists\n"
@@ -587,11 +587,6 @@ void vm_userspace_mem_region_add(struct kvm_vm *vm,
region = region->next) {
if (region->region.slot == slot)
break;
- if ((guest_paddr <= (region->region.guest_phys_addr
- + region->region.memory_size))
- && ((guest_paddr + npages * vm->page_size)
- >= region->region.guest_phys_addr))
- break;
}
if (region != NULL)
TEST_ASSERT(false, "A mem region with the requested slot "
--
2.20.1.97.g81188d93c3-goog