]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
Merge tag 'linux-kselftest-5.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 7 May 2019 03:29:45 +0000 (20:29 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 7 May 2019 03:29:45 +0000 (20:29 -0700)
Pull Kselftest updates from Shuah Khan:

 - fixes to seccomp test, and kselftest framework

 - cleanups to remove duplicate header defines

 - fixes to efivarfs "make clean" target

 - cgroup cleanup path

 - Moving the IMA kexec_load selftest to selftests/kexec work from Mimi
   Johar and Petr Vorel

 - A framework to kselftest for writing kernel test modules addition
   from Tobin C. Harding

* tag 'linux-kselftest-5.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: (29 commits)
  selftests: build and run gpio when output directory is the src dir
  selftests/ipc: Fix msgque compiler warnings
  selftests/efivarfs: clean up test files from test_create*()
  selftests: fix headers_install circular dependency
  selftests/kexec: update get_secureboot_mode
  selftests/kexec: make kexec_load test independent of IMA being enabled
  selftests/kexec: check kexec_load and kexec_file_load are enabled
  selftests/kexec: Add missing '=y' to config options
  selftests/kexec: kexec_file_load syscall test
  selftests/kexec: define "require_root_privileges"
  selftests/kexec: define common logging functions
  selftests/kexec: define a set of common functions
  selftests/kexec: cleanup the kexec selftest
  selftests/kexec: move the IMA kexec_load selftest to selftests/kexec
  selftests/harness: Add 30 second timeout per test
  selftests/seccomp: Handle namespace failures gracefully
  selftests: cgroup: fix cleanup path in test_memcg_subtree_control()
  selftests: efivarfs: remove the test_create_read file if it was exist
  rseq/selftests: Adapt number of threads to the number of detected cpus
  lib: Add test module for strscpy_pad
  ...

1  2 
lib/Kconfig.debug
lib/Makefile
tools/testing/selftests/seccomp/seccomp_bpf.c

diff --combined lib/Kconfig.debug
index d5a4a4036d2f83db9df1c5e2183380f900e62ca3,4b644ad399dd4696dd7889d5bb3f2a81f681b5db..4c54a89f06ee17b7532bd90707bfd1e4975cf0d4
@@@ -753,9 -753,9 +753,9 @@@ endmenu # "Memory Debugging
  config ARCH_HAS_KCOV
        bool
        help
 -        KCOV does not have any arch-specific code, but currently it is enabled
 -        only for x86_64. KCOV requires testing on other archs, and most likely
 -        disabling of instrumentation for some early boot code.
 +        An architecture should select this when it can successfully
 +        build and run with CONFIG_KCOV. This typically requires
 +        disabling instrumentation for some early boot code.
  
  config CC_HAS_SANCOV_TRACE_PC
        def_bool $(cc-option,-fsanitize-coverage=trace-pc)
@@@ -1769,6 -1769,9 +1769,9 @@@ config TEST_HEXDUM
  config TEST_STRING_HELPERS
        tristate "Test functions located in the string_helpers module at runtime"
  
+ config TEST_STRSCPY
+       tristate "Test strscpy*() family of functions at runtime"
  config TEST_KSTRTOX
        tristate "Test kstrto*() family of functions at runtime"
  
@@@ -1929,7 -1932,6 +1932,7 @@@ config TEST_KMO
        depends on m
        depends on BLOCK && (64BIT || LBDAF)      # for XFS, BTRFS
        depends on NETDEVICES && NET_CORE && INET # for TUN
 +      depends on BLOCK
        select TEST_LKM
        select XFS_FS
        select TUN
diff --combined lib/Makefile
index e16e7aadc41a5358e8fdc08cd585a1f6c7c9539a,b4e08d6234bab43fd22d9d17102f9fae891ad461..07506e3891a084d2ac4017bb8c2cec0e5e57f315
@@@ -17,17 -17,6 +17,17 @@@ KCOV_INSTRUMENT_list_debug.o := 
  KCOV_INSTRUMENT_debugobjects.o := n
  KCOV_INSTRUMENT_dynamic_debug.o := n
  
 +# Early boot use of cmdline, don't instrument it
 +ifdef CONFIG_AMD_MEM_ENCRYPT
 +KASAN_SANITIZE_string.o := n
 +
 +ifdef CONFIG_FUNCTION_TRACER
 +CFLAGS_REMOVE_string.o = -pg
 +endif
 +
 +CFLAGS_string.o := $(call cc-option, -fno-stack-protector)
 +endif
 +
  lib-y := ctype.o string.o vsprintf.o cmdline.o \
         rbtree.o radix-tree.o timerqueue.o xarray.o \
         idr.o int_sqrt.o extable.o \
@@@ -81,6 -70,7 +81,7 @@@ obj-$(CONFIG_TEST_STATIC_KEYS) += test_
  obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_key_base.o
  obj-$(CONFIG_TEST_PRINTF) += test_printf.o
  obj-$(CONFIG_TEST_BITMAP) += test_bitmap.o
+ obj-$(CONFIG_TEST_STRSCPY) += test_strscpy.o
  obj-$(CONFIG_TEST_BITFIELD) += test_bitfield.o
  obj-$(CONFIG_TEST_UUID) += test_uuid.o
  obj-$(CONFIG_TEST_XARRAY) += test_xarray.o
@@@ -279,7 -269,6 +280,7 @@@ obj-$(CONFIG_UCS2_STRING) += ucs2_strin
  obj-$(CONFIG_UBSAN) += ubsan.o
  
  UBSAN_SANITIZE_ubsan.o := n
 +CFLAGS_ubsan.o := $(call cc-option, -fno-conserve-stack -fno-stack-protector)
  
  obj-$(CONFIG_SBITMAP) += sbitmap.o
  
index 5019cdae5d0b8ca8a47692c71956d9f824812466,3a280b7efc876ccff8c4583a7296c9a75d8d3124..0fad0dc6233865bf5a20293070223ffeaf703c23
@@@ -2166,14 -2166,11 +2166,14 @@@ TEST(detect_seccomp_filter_flags
                                 SECCOMP_FILTER_FLAG_LOG,
                                 SECCOMP_FILTER_FLAG_SPEC_ALLOW,
                                 SECCOMP_FILTER_FLAG_NEW_LISTENER };
 -      unsigned int flag, all_flags;
 +      unsigned int exclusive[] = {
 +                              SECCOMP_FILTER_FLAG_TSYNC,
 +                              SECCOMP_FILTER_FLAG_NEW_LISTENER };
 +      unsigned int flag, all_flags, exclusive_mask;
        int i;
        long ret;
  
 -      /* Test detection of known-good filter flags */
 +      /* Test detection of individual known-good filter flags */
        for (i = 0, all_flags = 0; i < ARRAY_SIZE(flags); i++) {
                int bits = 0;
  
                all_flags |= flag;
        }
  
 -      /* Test detection of all known-good filter flags */
 -      ret = seccomp(SECCOMP_SET_MODE_FILTER, all_flags, NULL);
 -      EXPECT_EQ(-1, ret);
 -      EXPECT_EQ(EFAULT, errno) {
 -              TH_LOG("Failed to detect that all known-good filter flags (0x%X) are supported!",
 -                     all_flags);
 +      /*
 +       * Test detection of all known-good filter flags combined. But
 +       * for the exclusive flags we need to mask them out and try them
 +       * individually for the "all flags" testing.
 +       */
 +      exclusive_mask = 0;
 +      for (i = 0; i < ARRAY_SIZE(exclusive); i++)
 +              exclusive_mask |= exclusive[i];
 +      for (i = 0; i < ARRAY_SIZE(exclusive); i++) {
 +              flag = all_flags & ~exclusive_mask;
 +              flag |= exclusive[i];
 +
 +              ret = seccomp(SECCOMP_SET_MODE_FILTER, flag, NULL);
 +              EXPECT_EQ(-1, ret);
 +              EXPECT_EQ(EFAULT, errno) {
 +                      TH_LOG("Failed to detect that all known-good filter flags (0x%X) are supported!",
 +                             flag);
 +              }
        }
  
 -      /* Test detection of an unknown filter flag */
 +      /* Test detection of an unknown filter flags, without exclusives. */
        flag = -1;
 +      flag &= ~exclusive_mask;
        ret = seccomp(SECCOMP_SET_MODE_FILTER, flag, NULL);
        EXPECT_EQ(-1, ret);
        EXPECT_EQ(EINVAL, errno) {
@@@ -3095,9 -3079,9 +3095,9 @@@ TEST(user_notification_basic
  
        /* Check that we get -ENOSYS with no listener attached */
        if (pid == 0) {
-               if (user_trap_syscall(__NR_getpid, 0) < 0)
+               if (user_trap_syscall(__NR_getppid, 0) < 0)
                        exit(1);
-               ret = syscall(__NR_getpid);
+               ret = syscall(__NR_getppid);
                exit(ret >= 0 || errno != ENOSYS);
        }
  
        EXPECT_EQ(seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog), 0);
  
        /* Check that the basic notification machinery works */
-       listener = user_trap_syscall(__NR_getpid,
+       listener = user_trap_syscall(__NR_getppid,
                                     SECCOMP_FILTER_FLAG_NEW_LISTENER);
        ASSERT_GE(listener, 0);
  
        /* Installing a second listener in the chain should EBUSY */
-       EXPECT_EQ(user_trap_syscall(__NR_getpid,
+       EXPECT_EQ(user_trap_syscall(__NR_getppid,
                                    SECCOMP_FILTER_FLAG_NEW_LISTENER),
                  -1);
        EXPECT_EQ(errno, EBUSY);
        ASSERT_GE(pid, 0);
  
        if (pid == 0) {
-               ret = syscall(__NR_getpid);
+               ret = syscall(__NR_getppid);
                exit(ret != USER_NOTIF_MAGIC);
        }
  
        EXPECT_GT(poll(&pollfd, 1, -1), 0);
        EXPECT_EQ(pollfd.revents, POLLOUT);
  
-       EXPECT_EQ(req.data.nr,  __NR_getpid);
+       EXPECT_EQ(req.data.nr,  __NR_getppid);
  
        resp.id = req.id;
        resp.error = 0;
@@@ -3176,7 -3160,7 +3176,7 @@@ TEST(user_notification_kill_in_middle
                TH_LOG("Kernel does not support PR_SET_NO_NEW_PRIVS!");
        }
  
-       listener = user_trap_syscall(__NR_getpid,
+       listener = user_trap_syscall(__NR_getppid,
                                     SECCOMP_FILTER_FLAG_NEW_LISTENER);
        ASSERT_GE(listener, 0);
  
        ASSERT_GE(pid, 0);
  
        if (pid == 0) {
-               ret = syscall(__NR_getpid);
+               ret = syscall(__NR_getppid);
                exit(ret != USER_NOTIF_MAGIC);
        }
  
@@@ -3298,7 -3282,7 +3298,7 @@@ TEST(user_notification_closed_listener
                TH_LOG("Kernel does not support PR_SET_NO_NEW_PRIVS!");
        }
  
-       listener = user_trap_syscall(__NR_getpid,
+       listener = user_trap_syscall(__NR_getppid,
                                     SECCOMP_FILTER_FLAG_NEW_LISTENER);
        ASSERT_GE(listener, 0);
  
        ASSERT_GE(pid, 0);
        if (pid == 0) {
                close(listener);
-               ret = syscall(__NR_getpid);
+               ret = syscall(__NR_getppid);
                exit(ret != -1 && errno != ENOSYS);
        }
  
@@@ -3332,14 -3316,15 +3332,15 @@@ TEST(user_notification_child_pid_ns
  
        ASSERT_EQ(unshare(CLONE_NEWUSER | CLONE_NEWPID), 0);
  
-       listener = user_trap_syscall(__NR_getpid, SECCOMP_FILTER_FLAG_NEW_LISTENER);
+       listener = user_trap_syscall(__NR_getppid,
+                                    SECCOMP_FILTER_FLAG_NEW_LISTENER);
        ASSERT_GE(listener, 0);
  
        pid = fork();
        ASSERT_GE(pid, 0);
  
        if (pid == 0)
-               exit(syscall(__NR_getpid) != USER_NOTIF_MAGIC);
+               exit(syscall(__NR_getppid) != USER_NOTIF_MAGIC);
  
        EXPECT_EQ(ioctl(listener, SECCOMP_IOCTL_NOTIF_RECV, &req), 0);
        EXPECT_EQ(req.pid, pid);
@@@ -3371,7 -3356,8 +3372,8 @@@ TEST(user_notification_sibling_pid_ns
                TH_LOG("Kernel does not support PR_SET_NO_NEW_PRIVS!");
        }
  
-       listener = user_trap_syscall(__NR_getpid, SECCOMP_FILTER_FLAG_NEW_LISTENER);
+       listener = user_trap_syscall(__NR_getppid,
+                                    SECCOMP_FILTER_FLAG_NEW_LISTENER);
        ASSERT_GE(listener, 0);
  
        pid = fork();
                ASSERT_GE(pid2, 0);
  
                if (pid2 == 0)
-                       exit(syscall(__NR_getpid) != USER_NOTIF_MAGIC);
+                       exit(syscall(__NR_getppid) != USER_NOTIF_MAGIC);
  
                EXPECT_EQ(waitpid(pid2, &status, 0), pid2);
                EXPECT_EQ(true, WIFEXITED(status));
        }
  
        /* Create the sibling ns, and sibling in it. */
-       EXPECT_EQ(unshare(CLONE_NEWPID), 0);
-       EXPECT_EQ(errno, 0);
+       ASSERT_EQ(unshare(CLONE_NEWPID), 0);
+       ASSERT_EQ(errno, 0);
  
        pid2 = fork();
-       EXPECT_GE(pid2, 0);
+       ASSERT_GE(pid2, 0);
  
        if (pid2 == 0) {
                ASSERT_EQ(ioctl(listener, SECCOMP_IOCTL_NOTIF_RECV, &req), 0);
                 * The pid should be 0, i.e. the task is in some namespace that
                 * we can't "see".
                 */
-               ASSERT_EQ(req.pid, 0);
+               EXPECT_EQ(req.pid, 0);
  
                resp.id = req.id;
                resp.error = 0;
@@@ -3435,14 -3421,15 +3437,15 @@@ TEST(user_notification_fault_recv
  
        ASSERT_EQ(unshare(CLONE_NEWUSER), 0);
  
-       listener = user_trap_syscall(__NR_getpid, SECCOMP_FILTER_FLAG_NEW_LISTENER);
+       listener = user_trap_syscall(__NR_getppid,
+                                    SECCOMP_FILTER_FLAG_NEW_LISTENER);
        ASSERT_GE(listener, 0);
  
        pid = fork();
        ASSERT_GE(pid, 0);
  
        if (pid == 0)
-               exit(syscall(__NR_getpid) != USER_NOTIF_MAGIC);
+               exit(syscall(__NR_getppid) != USER_NOTIF_MAGIC);
  
        /* Do a bad recv() */
        EXPECT_EQ(ioctl(listener, SECCOMP_IOCTL_NOTIF_RECV, NULL), -1);