Skip to content

Commit 4d6cf24

Browse files
keesshuahkh
authored andcommitted
kunit/usercopy: Disable testing on !CONFIG_MMU
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>
1 parent cf6219e commit 4d6cf24

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

lib/kunit/user_alloc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ static int kunit_attach_mm(void)
3030
if (current->mm)
3131
return 0;
3232

33+
/* arch_pick_mmap_layout() is only sane with MMU systems. */
34+
if (!IS_ENABLED(CONFIG_MMU))
35+
return -EINVAL;
36+
3337
mm = mm_alloc();
3438
if (!mm)
3539
return -ENOMEM;

lib/usercopy_kunit.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,11 @@ static int usercopy_test_init(struct kunit *test)
290290
struct usercopy_test_priv *priv;
291291
unsigned long user_addr;
292292

293+
if (!IS_ENABLED(CONFIG_MMU)) {
294+
kunit_skip(test, "Userspace allocation testing not available on non-MMU systems");
295+
return 0;
296+
}
297+
293298
priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL);
294299
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv);
295300
test->priv = priv;

mm/util.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,9 @@ void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack)
484484
clear_bit(MMF_TOPDOWN, &mm->flags);
485485
}
486486
#endif
487+
#ifdef CONFIG_MMU
487488
EXPORT_SYMBOL_IF_KUNIT(arch_pick_mmap_layout);
489+
#endif
488490

489491
/**
490492
* __account_locked_vm - account locked pages to an mm's locked_vm

0 commit comments

Comments
 (0)