Hello,
I've been running execveat (execveat.c) locally on v6.1 and next-20240228.
It has flaky test case. There are some test cases which fail consistently.
The comment (not very clear) on top of failing cases is as following:
/*
* Execute as a long pathname relative to "/". If this is a script,
* the interpreter will launch but fail to open the script because its
* name ("/dev/fd/5/xxx....") is bigger than PATH_MAX.
*
* The failure code is usually 127 (POSIX: "If a command is not found,…
[View More]
* the exit status shall be 127."), but some systems give 126 (POSIX:
* "If the command name is found, but it is not an executable utility,
* the exit status shall be 126."), so allow either.
*/
The file name is just less than PATH_MAX (4096) and we are expecting the
execveat() to fail with particular 99 or 127/128 error code. But kernel is
returning 1 error code. Snippet from full output:
# child 3493092 exited with 1 not 99 nor 99
# child 3493094 exited with 1 not 127 nor 126
I'm not sure if test is wrong or the kernel has changed the return error codes.
Full test run output:
./execveat
TAP version 13
1..51
ok 1 Check success of execveat(3, '../execveat', 0)...
ok 2 Check success of execveat(5, 'execveat', 0)...
ok 3 Check success of execveat(7, 'execveat', 0)...
ok 4 Check success of execveat(-100,
'/home/usama/repos/ke...ftests/exec/execveat', 0)...
ok 5 Check success of execveat(99,
'/home/usama/repos/ke...ftests/exec/execveat', 0)...
ok 6 Check success of execveat(9, '', 4096)...
ok 7 Check success of execveat(18, '', 4096)...
ok 8 Check success of execveat(10, '', 4096)...
ok 9 Check success of execveat(15, '', 4096)...
ok 10 Check success of execveat(15, '', 4096)...
ok 11 Check success of execveat(16, '', 4096)...
ok 12 Check failure of execveat(9, '', 0) with ENOENT
ok 13 Check failure of execveat(9, '(null)', 4096) with EFAULT
ok 14 Check success of execveat(5, 'execveat.symlink', 0)...
ok 15 Check success of execveat(7, 'execveat.symlink', 0)...
ok 16 Check success of execveat(-100,
'/home/usama/repos/ke...xec/execveat.symlink', 0)...
ok 17 Check success of execveat(11, '', 4096)...
ok 18 Check success of execveat(11, '', 4352)...
ok 19 Check failure of execveat(5, 'execveat.symlink', 256) with ELOOP
ok 20 Check failure of execveat(7, 'execveat.symlink', 256) with ELOOP
ok 21 Check failure of execveat(-100,
'/home/usama/repos/kernel/linux_mainline/tools/testing/selftests/exec/execveat.symlink',
256) with ELOOP
ok 22 Check failure of execveat(5, 'pipe', 0) with EACCES
ok 23 Check success of execveat(3, '../script', 0)...
ok 24 Check success of execveat(5, 'script', 0)...
ok 25 Check success of execveat(7, 'script', 0)...
ok 26 Check success of execveat(-100,
'/home/usama/repos/ke...elftests/exec/script', 0)...
ok 27 Check success of execveat(14, '', 4096)...
ok 28 Check success of execveat(14, '', 4352)...
ok 29 Check failure of execveat(19, '', 4096) with ENOENT
ok 30 Check failure of execveat(8, 'script', 0) with ENOENT
ok 31 Check success of execveat(17, '', 4096)...
ok 32 Check success of execveat(17, '', 4096)...
ok 33 Check success of execveat(4, '../script', 0)...
ok 34 Check success of execveat(4, 'script', 0)...
ok 35 Check success of execveat(4, '../script', 0)...
ok 36 Check failure of execveat(4, 'script', 0) with ENOENT
ok 37 Check failure of execveat(5, 'execveat', 65535) with EINVAL
ok 38 Check failure of execveat(5, 'no-such-file', 0) with ENOENT
ok 39 Check failure of execveat(7, 'no-such-file', 0) with ENOENT
ok 40 Check failure of execveat(-100, 'no-such-file', 0) with ENOENT
ok 41 Check failure of execveat(5, '', 4096) with EACCES
ok 42 Check failure of execveat(5, 'Makefile', 0) with EACCES
ok 43 Check failure of execveat(12, '', 4096) with EACCES
ok 44 Check failure of execveat(13, '', 4096) with EACCES
ok 45 Check failure of execveat(99, '', 4096) with EBADF
ok 46 Check failure of execveat(99, 'execveat', 0) with EBADF
ok 47 Check failure of execveat(9, 'execveat', 0) with ENOTDIR
# Invoke copy of 'execveat' via filename of length 4094:
ok 48 Check success of execveat(20, '', 4096)...
# execveat() failed, rc=-1 errno=2 (No such file or directory)
not ok 49 Check success of execveat(6,
'home/usama/repos/ker...yyyyyyyyyyyyyyyyyyyy', 0)...
# child 3493092 exited with 1 not 99 nor 99
not ok 49 Check success of execveat(6,
'home/usama/repos/ker...yyyyyyyyyyyyyyyyyyyy', 0)...
# Invoke copy of 'script' via filename of length 4094:
ok 50 Check success of execveat(21, '', 4096)...
# execveat() failed, rc=-1 errno=2 (No such file or directory)
not ok 51 Check success of execveat(6,
'home/usama/repos/ker...yyyyyyyyyyyyyyyyyyyy', 0)...
# child 3493094 exited with 1 not 127 nor 126
not ok 51 Check success of execveat(6,
'home/usama/repos/ker...yyyyyyyyyyyyyyyyyyyy', 0)...
2 tests failed
# Totals: pass:49 fail:2 xfail:0 xpass:0 skip:0 error:0
--
BR,
Muhammad Usama Anjum
[View Less]
This patchset adds KVM selftests for LoongArch system, currently only
some common test cases are supported and pass to run. These testcase
are listed as following:
demand_paging_test
dirty_log_perf_test
dirty_log_test
guest_print_test
hardware_disable_test
kvm_binary_stats_test
kvm_create_max_vcpus
kvm_page_table_test
memslot_modification_stress_test
memslot_perf_test
set_memory_region_test
This patchset …
[View More]originally is posted from zhaotianrui, I continue to work
on his efforts.
---
Changes in v7:
1. Refine code to add LoongArch support in test case
set_memory_region_test.
Changes in v6:
1. Refresh the patch based on latest kernel 6.8-rc1, add LoongArch
support about testcase set_memory_region_test.
2. Add hardware_disable_test test case.
3. Drop modification about macro DEFAULT_GUEST_TEST_MEM, it is problem
of LoongArch binutils, this issue is raised to LoongArch binutils owners.
Changes in v5:
1. In LoongArch kvm self tests, the DEFAULT_GUEST_TEST_MEM could be
0x130000000, it is different from the default value in memstress.h.
So we Move the definition of DEFAULT_GUEST_TEST_MEM into LoongArch
ucall.h, and add 'ifndef' condition for DEFAULT_GUEST_TEST_MEM
in memstress.h.
Changes in v4:
1. Remove the based-on flag, as the LoongArch KVM patch series
have been accepted by Linux kernel, so this can be applied directly
in kernel.
Changes in v3:
1. Improve implementation of LoongArch VM page walk.
2. Add exception handler for LoongArch.
3. Add dirty_log_test, dirty_log_perf_test, guest_print_test
test cases for LoongArch.
4. Add __ASSEMBLER__ macro to distinguish asm file and c file.
5. Move ucall_arch_do_ucall to the header file and make it as
static inline to avoid function calls.
6. Change the DEFAULT_GUEST_TEST_MEM base addr for LoongArch.
Changes in v2:
1. We should use ".balign 4096" to align the assemble code with 4K in
exception.S instead of "align 12".
2. LoongArch only supports 3 or 4 levels page tables, so we remove the
hanlders for 2-levels page table.
3. Remove the DEFAULT_LOONGARCH_GUEST_STACK_VADDR_MIN and use the common
DEFAULT_GUEST_STACK_VADDR_MIN to allocate stack memory in guest.
4. Reorganize the test cases supported by LoongArch.
5. Fix some code comments.
6. Add kvm_binary_stats_test test case into LoongArch KVM selftests.
---
Tianrui Zhao (4):
KVM: selftests: Add KVM selftests header files for LoongArch
KVM: selftests: Add core KVM selftests support for LoongArch
KVM: selftests: Add ucall test support for LoongArch
KVM: selftests: Add test cases for LoongArch
tools/testing/selftests/kvm/Makefile | 16 +
.../selftests/kvm/include/kvm_util_base.h | 5 +
.../kvm/include/loongarch/processor.h | 133 +++++++
.../selftests/kvm/include/loongarch/ucall.h | 20 ++
.../selftests/kvm/lib/loongarch/exception.S | 59 ++++
.../selftests/kvm/lib/loongarch/processor.c | 332 ++++++++++++++++++
.../selftests/kvm/lib/loongarch/ucall.c | 38 ++
.../selftests/kvm/set_memory_region_test.c | 2 +-
8 files changed, 604 insertions(+), 1 deletion(-)
create mode 100644 tools/testing/selftests/kvm/include/loongarch/processor.h
create mode 100644 tools/testing/selftests/kvm/include/loongarch/ucall.h
create mode 100644 tools/testing/selftests/kvm/lib/loongarch/exception.S
create mode 100644 tools/testing/selftests/kvm/lib/loongarch/processor.c
create mode 100644 tools/testing/selftests/kvm/lib/loongarch/ucall.c
base-commit: 6764c317b6bb91bd806ef79adf6d9c0e428b191e
--
2.39.3
[View Less]
Hi Linus,
Please pull these small execve updates for v6.9-rc1. Details below.
Thanks!
-Kees
The following changes since commit 41bccc98fb7931d63d03f326a746ac4d429c1dd3:
Linux 6.8-rc2 (2024-01-28 17:01:12 -0800)
are available in the Git repository at:
https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git tags/execve-v6.9-rc1
for you to fetch changes up to 725d50261285ccf02501f2a1a6d10b31ce014597:
exec: Simplify remove_arg_zero() error path (2024-03-09 13:46:30 -0800)
----…
[View More]------------------------------------------------------------
execve updates for v6.9-rc1
- Drop needless error path code in remove_arg_zero() (Li kunyu, Kees Cook)
- binfmt_elf_efpic: Don't use missing interpreter's properties (Max Filippov)
- Use /bin/bash for execveat selftests
----------------------------------------------------------------
Kees Cook (2):
selftests/exec: Perform script checks with /bin/bash
exec: Simplify remove_arg_zero() error path
Li kunyu (1):
exec: Delete unnecessary statements in remove_arg_zero()
Max Filippov (1):
fs: binfmt_elf_efpic: don't use missing interpreter's properties
fs/binfmt_elf_fdpic.c | 2 +-
fs/exec.c | 11 +++--------
tools/testing/selftests/exec/execveat.c | 2 +-
3 files changed, 5 insertions(+), 10 deletions(-)
--
Kees Cook
[View Less]
Hi,
Routine run of the test in net-next gave also this mm unit error.
root@defiant:tools/testing/selftests/mm# ./uffd-unit-tests
Testing UFFDIO_API (with syscall)... done
Testing UFFDIO_API (with /dev/userfaultfd)... done
Testing register-ioctls on anon... done
Testing register-ioctls on shmem... done
Testing register-ioctls on shmem-private... done
Testing register-ioctls on hugetlb... skipped [reason: memory allocation failed]
Testing register-ioctls on hugetlb-private... skipped [reason: …
[View More]memory allocation failed]
Testing zeropage on anon... done
Testing zeropage on shmem... done
Testing zeropage on shmem-private... done
Testing zeropage on hugetlb... skipped [reason: memory allocation failed]
Testing zeropage on hugetlb-private... skipped [reason: memory allocation failed]
Testing move on anon... done
Testing move-pmd on anon... done
Testing move-pmd-split on anon... done
Testing wp-fork on anon... done
Testing wp-fork on shmem... done
Testing wp-fork on shmem-private... done
Testing wp-fork on hugetlb... skipped [reason: memory allocation failed]
Testing wp-fork on hugetlb-private... skipped [reason: memory allocation failed]
Testing wp-fork-with-event on anon... done
Testing wp-fork-with-event on shmem... done
Testing wp-fork-with-event on shmem-private... done
Testing wp-fork-with-event on hugetlb... skipped [reason: memory allocation failed]
Testing wp-fork-with-event on hugetlb-private... skipped [reason: memory allocation failed]
Testing wp-fork-pin on anon... done
Testing wp-fork-pin on shmem... done
Testing wp-fork-pin on shmem-private... done
Testing wp-fork-pin on hugetlb... skipped [reason: memory allocation failed]
Testing wp-fork-pin on hugetlb-private... skipped [reason: memory allocation failed]
Testing wp-fork-pin-with-event on anon... done
Testing wp-fork-pin-with-event on shmem... done
Testing wp-fork-pin-with-event on shmem-private... done
Testing wp-fork-pin-with-event on hugetlb... skipped [reason: memory allocation failed]
Testing wp-fork-pin-with-event on hugetlb-private... skipped [reason: memory allocation failed]
Testing wp-unpopulated on anon... done
Testing minor on shmem... done
Testing minor on hugetlb... skipped [reason: memory allocation failed]
Testing minor-wp on shmem... done
Testing minor-wp on hugetlb... skipped [reason: memory allocation failed]
Testing minor-collapse on shmem... done
Testing sigbus on anon... done
Testing sigbus on shmem... done
Testing sigbus on shmem-private... done
Testing sigbus on hugetlb... skipped [reason: memory allocation failed]
Testing sigbus on hugetlb-private... skipped [reason: memory allocation failed]
Testing sigbus-wp on anon... done
Testing sigbus-wp on shmem... done
Testing sigbus-wp on shmem-private... done
Testing sigbus-wp on hugetlb... skipped [reason: memory allocation failed]
Testing sigbus-wp on hugetlb-private... skipped [reason: memory allocation failed]
Testing events on anon... done
Testing events on shmem... done
Testing events on shmem-private... done
Testing events on hugetlb... skipped [reason: memory allocation failed]
Testing events on hugetlb-private... skipped [reason: memory allocation failed]
Testing events-wp on anon... done
Testing events-wp on shmem... done
Testing events-wp on shmem-private... done
Testing events-wp on hugetlb... skipped [reason: memory allocation failed]
Testing events-wp on hugetlb-private... skipped [reason: memory allocation failed]
Testing poison on anon... done
Testing poison on shmem... done
Testing poison on shmem-private... done
Testing poison on hugetlb... skipped [reason: memory allocation failed]
Testing poison on hugetlb-private... skipped [reason: memory allocation failed]
Userfaults unit tests: pass=42, skip=24, fail=0 (total=66)
root@defiant:tools/testing/selftests/mm# grep -i huge /proc/meminfo
It resulted in alarming errors in the syslog:
Mar 9 19:48:24 defiant kernel: [77187.055103] MCE: Killing uffd-unit-tests:1321817 due to hardware memory corruption fault at 4631e000
Mar 9 19:48:24 defiant kernel: [77187.055132] MCE: Killing uffd-unit-tests:1321817 due to hardware memory corruption fault at 46320000
Mar 9 19:48:24 defiant kernel: [77187.055160] MCE: Killing uffd-unit-tests:1321817 due to hardware memory corruption fault at 46322000
Mar 9 19:48:24 defiant kernel: [77187.055189] MCE: Killing uffd-unit-tests:1321817 due to hardware memory corruption fault at 46324000
Mar 9 19:48:24 defiant kernel: [77187.055218] MCE: Killing uffd-unit-tests:1321817 due to hardware memory corruption fault at 46326000
Mar 9 19:48:24 defiant kernel: [77187.055250] MCE: Killing uffd-unit-tests:1321817 due to hardware memory corruption fault at 46328000
Mar 9 19:48:24 defiant kernel: [77187.055278] MCE: Killing uffd-unit-tests:1321817 due to hardware memory corruption fault at 4632a000
Mar 9 19:48:24 defiant kernel: [77187.055307] MCE: Killing uffd-unit-tests:1321817 due to hardware memory corruption fault at 4632c000
Mar 9 19:48:24 defiant kernel: [77187.055336] MCE: Killing uffd-unit-tests:1321817 due to hardware memory corruption fault at 4632e000
Mar 9 19:48:24 defiant kernel: [77187.055366] MCE: Killing uffd-unit-tests:1321817 due to hardware memory corruption fault at 46330000
Mar 9 19:48:24 defiant kernel: [77187.055395] MCE: Killing uffd-unit-tests:1321817 due to hardware memory corruption fault at 46332000
Mar 9 19:48:24 defiant kernel: [77187.055423] MCE: Killing uffd-unit-tests:1321817 due to hardware memory corruption fault at 46334000
Mar 9 19:48:24 defiant kernel: [77187.055452] MCE: Killing uffd-unit-tests:1321817 due to hardware memory corruption fault at 46336000
Mar 9 19:48:24 defiant kernel: [77187.055480] MCE: Killing uffd-unit-tests:1321817 due to hardware memory corruption fault at 46338000
Mar 9 19:48:24 defiant kernel: [77187.055509] MCE: Killing uffd-unit-tests:1321817 due to hardware memory corruption fault at 4633a000
Mar 9 19:48:24 defiant kernel: [77187.055538] MCE: Killing uffd-unit-tests:1321817 due to hardware memory corruption fault at 4633c000
Mar 9 19:48:24 defiant kernel: [77187.055567] MCE: Killing uffd-unit-tests:1321817 due to hardware memory corruption fault at 4633e000
Mar 9 19:48:24 defiant kernel: [77187.055597] MCE: Killing uffd-unit-tests:1321817 due to hardware memory corruption fault at 46340000
At this point, it can be problem with my box's memory chips, or something with HUGETLB.
However, since the "classic" allocations were successful, the problem might be in huge pages, or
if I understood well, in deliberate poisoning of pages?
Please also find strace of the run.
Best regards,
Mirsad Todorovac
[View Less]
When using gcc without cross compiling, i.e., `CROSS_COMPILE` unset or
empty, the selftests build defaults to the host architecture, i.e., it uses
plain gcc. However, when compiling with clang an unset `ARCH` variable in
combination with an unset `CROSS_COMPILE` variable, i.e., compiling for
the host architecture, leads to compilation failures since `lib.mk` can
not determine the clang target triple. In this case, the following error
message is displayed for each subsystem that does not set `…
[View More]ARCH` in its
own Makefile before including `lib.mk` (lines wrapped at 75 chrs):
make[1]: Entering directory '/mnt/build/linux/tools/testing/selftests/
sysctl'
../lib.mk:33: *** Specify CROSS_COMPILE or add '--target=' option to
lib.mk. Stop.
make[1]: Leaving directory '/mnt/build/linux/tools/testing/selftests/
sysctl'
Align the behavior for gcc and clang builds by interpreting unset
`ARCH` and `CROSS_COMPILE` variables in `LLVM` builds as a sign that the
user wants to build for the host architecture.
This preserves the property that setting the `ARCH` variable to an
unknown value will trigger an error that complains about insufficient
information.
RFC since I am not entirely sure if this behavior is in fact known and
intended, and whether the way to obtain the host target triple is
sufficiently general. (The flag was introduced in llvm-8 with [1], it
will be an error for older clang versions, however, currently 13.0.1 is the
minimal version required to build the kernel. For some clang binaries it
prints the 'unknown' instead of the 'linux' version of the target, e.g.,
mips [2]). An alternative could be to simply do:
ARCH ?= $(shell uname -m)
before using it to select the target. Possibly with some post processing,
but at that point we would likely be replicating `scripts/subarch.include`.
Also unsure if it needs a 'Fixes: 795285ef2425 ("selftests: Fix clang
cross compilation")'. Furthermore, this change might make it possible to
remove the explicit setting of `ARCH` from the few subsystem Makefiles
that do it.
Would be happy to get some feedback on those points. If it looks OK I
can also send it as a patch.
Link: https://reviews.llvm.org/D50755 [1]
Link: https://godbolt.org/z/r7Gn9bvv1 [2]
Signed-off-by: Valentin Obst <kernel(a)valentinobst.de>
---
tools/testing/selftests/lib.mk | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index aa646e0661f3..a8f0442a36bc 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -7,6 +7,8 @@ else ifneq ($(filter -%,$(LLVM)),)
LLVM_SUFFIX := $(LLVM)
endif
+CLANG := $(LLVM_PREFIX)clang$(LLVM_SUFFIX)
+
CLANG_TARGET_FLAGS_arm := arm-linux-gnueabi
CLANG_TARGET_FLAGS_arm64 := aarch64-linux-gnu
CLANG_TARGET_FLAGS_hexagon := hexagon-linux-musl
@@ -18,7 +20,13 @@ CLANG_TARGET_FLAGS_riscv := riscv64-linux-gnu
CLANG_TARGET_FLAGS_s390 := s390x-linux-gnu
CLANG_TARGET_FLAGS_x86 := x86_64-linux-gnu
CLANG_TARGET_FLAGS_x86_64 := x86_64-linux-gnu
-CLANG_TARGET_FLAGS := $(CLANG_TARGET_FLAGS_$(ARCH))
+
+# Default to host architecture if ARCH is not explicitly given.
+ifeq ($(ARCH),)
+CLANG_TARGET_FLAGS := $(shell $(CLANG) -print-target-triple)
+else
+CLANG_TARGET_FLAGS := $(CLANG_TARGET_FLAGS_$(ARCH))
+endif
ifeq ($(CROSS_COMPILE),)
ifeq ($(CLANG_TARGET_FLAGS),)
@@ -30,7 +38,7 @@ else
CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%))
endif # CROSS_COMPILE
-CC := $(LLVM_PREFIX)clang$(LLVM_SUFFIX) $(CLANG_FLAGS) -fintegrated-as
+CC := $(CLANG) $(CLANG_FLAGS) -fintegrated-as
else
CC := $(CROSS_COMPILE)gcc
endif # LLVM
---
base-commit: d206a76d7d2726f3b096037f2079ce0bd3ba329b
change-id: 20240303-selftests-libmk-llvm-rfc-5fe3cfa9f094
Best regards,
--
Valentin Obst <kernel(a)valentinobst.de>
[View Less]