Merge tag 'linux_kselftest-fixes-6.10-rc5' of git://git.kernel.org/pub/scm/linux...
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 18 Jun 2024 20:36:43 +0000 (13:36 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 18 Jun 2024 20:36:43 +0000 (13:36 -0700)
Pull kselftest fixes from Shuah Khan:

 - filesystems: warn_unused_result warnings

 - seccomp: format-zero-length warnings

 - fchmodat2: clang build warnings due to-static-libasan

 - openat2: clang build warnings due to static-libasan, LOCAL_HDRS

* tag 'linux_kselftest-fixes-6.10-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
  selftests/fchmodat2: fix clang build failure due to -static-libasan
  selftests/openat2: fix clang build failures: -static-libasan, LOCAL_HDRS
  selftests: seccomp: fix format-zero-length warnings
  selftests: filesystems: fix warn_unused_result build warnings

tools/testing/selftests/fchmodat2/Makefile
tools/testing/selftests/filesystems/statmount/statmount_test.c
tools/testing/selftests/openat2/Makefile
tools/testing/selftests/seccomp/seccomp_benchmark.c

index 71ec34bf1501e275cbf229861dc6daad59fd905f..4373cea79b79414bfce59b0b3dadc14dc5cecf21 100644 (file)
@@ -1,6 +1,15 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 
-CFLAGS += -Wall -O2 -g -fsanitize=address -fsanitize=undefined -static-libasan $(KHDR_INCLUDES)
+CFLAGS += -Wall -O2 -g -fsanitize=address -fsanitize=undefined $(KHDR_INCLUDES)
+
+# gcc requires -static-libasan in order to ensure that Address Sanitizer's
+# library is the first one loaded. However, clang already statically links the
+# Address Sanitizer if -fsanitize is specified. Therefore, simply omit
+# -static-libasan for clang builds.
+ifeq ($(LLVM),)
+    CFLAGS += -static-libasan
+endif
+
 TEST_GEN_PROGS := fchmodat2_test
 
 include ../lib.mk
index e6d7c4f1c85b50503c90056cae2d537b80710dd0..e8c019d72cbf3d544fc7d1b0e89f9f9288003158 100644 (file)
@@ -125,8 +125,16 @@ static uint32_t old_root_id, old_parent_id;
 
 static void cleanup_namespace(void)
 {
-       fchdir(orig_root);
-       chroot(".");
+       int ret;
+
+       ret = fchdir(orig_root);
+       if (ret == -1)
+               ksft_perror("fchdir to original root");
+
+       ret = chroot(".");
+       if (ret == -1)
+               ksft_perror("chroot to original root");
+
        umount2(root_mntpoint, MNT_DETACH);
        rmdir(root_mntpoint);
 }
index 254d676a2689835727155a35455fca128b0636f2..185dc76ebb5fc44a63624a2d9795b2afc40b7a6c 100644 (file)
@@ -1,8 +1,18 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 
-CFLAGS += -Wall -O2 -g -fsanitize=address -fsanitize=undefined -static-libasan
+CFLAGS += -Wall -O2 -g -fsanitize=address -fsanitize=undefined
 TEST_GEN_PROGS := openat2_test resolve_test rename_attack_test
 
+# gcc requires -static-libasan in order to ensure that Address Sanitizer's
+# library is the first one loaded. However, clang already statically links the
+# Address Sanitizer if -fsanitize is specified. Therefore, simply omit
+# -static-libasan for clang builds.
+ifeq ($(LLVM),)
+    CFLAGS += -static-libasan
+endif
+
+LOCAL_HDRS += helpers.h
+
 include ../lib.mk
 
-$(TEST_GEN_PROGS): helpers.c helpers.h
+$(TEST_GEN_PROGS): helpers.c
index b83099160fbcaae141146795ae718a4cdbd7fa26..94886c82ae609f890965b03a4207f53a8b5ec3f6 100644 (file)
@@ -194,14 +194,14 @@ int main(int argc, char *argv[])
        ksft_set_plan(7);
 
        ksft_print_msg("Running on:\n");
-       ksft_print_msg("");
+       ksft_print_msg("%s", "");
        system("uname -a");
 
        ksft_print_msg("Current BPF sysctl settings:\n");
        /* Avoid using "sysctl" which may not be installed. */
-       ksft_print_msg("");
+       ksft_print_msg("%s", "");
        system("grep -H . /proc/sys/net/core/bpf_jit_enable");
-       ksft_print_msg("");
+       ksft_print_msg("%s", "");
        system("grep -H . /proc/sys/net/core/bpf_jit_harden");
 
        affinity();