]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
kunit/usercopy: Disable testing on !CONFIG_MMU
authorKees Cook <kees@kernel.org>
Wed, 19 Jun 2024 20:25:17 +0000 (13:25 -0700)
committerShuah Khan <skhan@linuxfoundation.org>
Tue, 2 Jul 2024 16:11:40 +0000 (10:11 -0600)
Since arch_pick_mmap_layout() is an inline for non-MMU systems, disable
this test there.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202406160505.uBge6TMY-lkp@intel.com/
Signed-off-by: Kees Cook <kees@kernel.org>
Reviewed-by: Rae Moar <rmoar@google.com>
Reviewed-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
lib/kunit/user_alloc.c
lib/usercopy_kunit.c
mm/util.c

index 76d3d1345ed7dea6e249334221f6fcad99721242..ae935df09a5eb6018c8c22b1bc432136c68021e6 100644 (file)
@@ -30,6 +30,10 @@ static int kunit_attach_mm(void)
        if (current->mm)
                return 0;
 
+       /* arch_pick_mmap_layout() is only sane with MMU systems. */
+       if (!IS_ENABLED(CONFIG_MMU))
+               return -EINVAL;
+
        mm = mm_alloc();
        if (!mm)
                return -ENOMEM;
index 45f1e558c4647ed7400d5caf3ef23c6169e9747c..e819561a540daffd14e63283ba2fe2724ade6fdb 100644 (file)
@@ -290,6 +290,11 @@ static int usercopy_test_init(struct kunit *test)
        struct usercopy_test_priv *priv;
        unsigned long user_addr;
 
+       if (!IS_ENABLED(CONFIG_MMU)) {
+               kunit_skip(test, "Userspace allocation testing not available on non-MMU systems");
+               return 0;
+       }
+
        priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL);
        KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv);
        test->priv = priv;
index df37c47d9374861f47127ca43dcdb26b7ba6bde4..e70e8e439258e04b23fd5e23f71f3eb5b437d8c1 100644 (file)
--- a/mm/util.c
+++ b/mm/util.c
@@ -484,7 +484,9 @@ void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack)
        clear_bit(MMF_TOPDOWN, &mm->flags);
 }
 #endif
+#ifdef CONFIG_MMU
 EXPORT_SYMBOL_IF_KUNIT(arch_pick_mmap_layout);
+#endif
 
 /**
  * __account_locked_vm - account locked pages to an mm's locked_vm