Re: [PATCH v3 1/2] kunit: test: Add vm_mmap() allocation resource manager
From: Kees Cook
Date: Thu Jun 27 2024 - 15:51:56 EST
On Sat, Jun 22, 2024 at 06:47:39AM -0700, Guenter Roeck wrote:
> Hi,
>
> On Wed, Jun 12, 2024 at 12:59:18PM -0700, Kees Cook wrote:
> > For tests that need to allocate using vm_mmap() (e.g. usercopy and
> > execve), provide the interface to have the allocation tracked by KUnit
> > itself. This requires bringing up a placeholder userspace mm.
> >
> > This combines my earlier attempt at this with Mark Rutland's version[1].
> >
> > Normally alloc_mm() and arch_pick_mmap_layout() aren't exported for
> > modules, so export these only for KUnit testing.
> >
> > Link: https://lore.kernel.org/lkml/20230321122514.1743889-2-mark.rutland@xxxxxxx/ [1]
>
> FWIW, not sure I understand what the above link has to do with this patch.
Both the above Link and this patch were implementing KUnit usercopy
tests (and the required infrastructure).
>
> > Co-developed-by: Mark Rutland <mark.rutland@xxxxxxx>
> > Signed-off-by: Mark Rutland <mark.rutland@xxxxxxx>
> > Reviewed-by: David Gow <davidgow@xxxxxxxxxx>
> > Signed-off-by: Kees Cook <kees@xxxxxxxxxx>
>
> This patch results in a build failure for nommu_kc705_defconfig if kunit tests
> are also enabled.
>
> ERROR: modpost: vmlinux: local symbol 'arch_pick_mmap_layout' was exported
>
> If CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT=n, CONFIG_MMU=n, and
> CONFIG_KUNIT=y, arch_pick_mmap_layout is exported. However, if
> CONFIG_MMU=n, it is declared as static inline function.
I replied in the other thread too, but this has had a fix pending:
https://lore.kernel.org/lkml/202406271005.4E767DAE@keescook/
I pinged the patch again today.
-Kees
--
Kees Cook