[PATCH v3 0/2] usercopy: Convert test_user_copy to KUnit test

Kees Cook posted 2 patches 1 year, 8 months ago
MAINTAINERS                                |   1 +
include/kunit/test.h                       |  17 ++
kernel/fork.c                              |   3 +
lib/Kconfig.debug                          |  21 +-
lib/Makefile                               |   2 +-
lib/kunit/Makefile                         |   1 +
lib/kunit/user_alloc.c                     | 113 +++++++++
lib/{test_user_copy.c => usercopy_kunit.c} | 282 ++++++++++-----------
mm/util.c                                  |   3 +
9 files changed, 288 insertions(+), 155 deletions(-)
create mode 100644 lib/kunit/user_alloc.c
rename lib/{test_user_copy.c => usercopy_kunit.c} (46%)
[PATCH v3 0/2] usercopy: Convert test_user_copy to KUnit test
Posted by Kees Cook 1 year, 8 months ago
Hi,

This builds on the proposal[1] from Mark and lets me convert the
existing usercopy selftest to KUnit. Besides adding this basic test to
the KUnit collection, it also opens the door for execve testing (which
depends on having a functional current->mm), and should provide the
basic infrastructure for adding Mark's much more complete usercopy tests.

 v3:
  - use MEMEQ KUnit helper (David)
  - exclude pathological address confusion test for systems with separate
    address spaces, noticed by David
  - add KUnit-conditional exports for alloc_mm() and arch_pick_mmap_layout()
    noticed by 0day
 v2: https://lore.kernel.org/lkml/20240610213055.it.075-kees@kernel.org/
 v1: https://lore.kernel.org/lkml/20240519190422.work.715-kees@kernel.org/

-Kees

[1] https://lore.kernel.org/lkml/20230321122514.1743889-2-mark.rutland@arm.com/

Kees Cook (2):
  kunit: test: Add vm_mmap() allocation resource manager
  usercopy: Convert test_user_copy to KUnit test

 MAINTAINERS                                |   1 +
 include/kunit/test.h                       |  17 ++
 kernel/fork.c                              |   3 +
 lib/Kconfig.debug                          |  21 +-
 lib/Makefile                               |   2 +-
 lib/kunit/Makefile                         |   1 +
 lib/kunit/user_alloc.c                     | 113 +++++++++
 lib/{test_user_copy.c => usercopy_kunit.c} | 282 ++++++++++-----------
 mm/util.c                                  |   3 +
 9 files changed, 288 insertions(+), 155 deletions(-)
 create mode 100644 lib/kunit/user_alloc.c
 rename lib/{test_user_copy.c => usercopy_kunit.c} (46%)

-- 
2.34.1
Re: [PATCH v3 0/2] usercopy: Convert test_user_copy to KUnit test
Posted by David Gow 1 year, 8 months ago
On Thu, 13 Jun 2024 at 03:59, Kees Cook <kees@kernel.org> wrote:
>
> Hi,
>
> This builds on the proposal[1] from Mark and lets me convert the
> existing usercopy selftest to KUnit. Besides adding this basic test to
> the KUnit collection, it also opens the door for execve testing (which
> depends on having a functional current->mm), and should provide the
> basic infrastructure for adding Mark's much more complete usercopy tests.
>
>  v3:
>   - use MEMEQ KUnit helper (David)
>   - exclude pathological address confusion test for systems with separate
>     address spaces, noticed by David
>   - add KUnit-conditional exports for alloc_mm() and arch_pick_mmap_layout()
>     noticed by 0day
>  v2: https://lore.kernel.org/lkml/20240610213055.it.075-kees@kernel.org/
>  v1: https://lore.kernel.org/lkml/20240519190422.work.715-kees@kernel.org/
>
> -Kees
>
> [1] https://lore.kernel.org/lkml/20230321122514.1743889-2-mark.rutland@arm.com/

Thanks! This looks good to me (and passes everything here). Unless
there's a compelling reason not to, I think we can take this via the
KUnit tree.

Cheers,
-- David
Re: [PATCH v3 0/2] usercopy: Convert test_user_copy to KUnit test
Posted by Kees Cook 1 year, 8 months ago
On Thu, Jun 13, 2024 at 12:41:43PM +0800, David Gow wrote:
> On Thu, 13 Jun 2024 at 03:59, Kees Cook <kees@kernel.org> wrote:
> >
> > Hi,
> >
> > This builds on the proposal[1] from Mark and lets me convert the
> > existing usercopy selftest to KUnit. Besides adding this basic test to
> > the KUnit collection, it also opens the door for execve testing (which
> > depends on having a functional current->mm), and should provide the
> > basic infrastructure for adding Mark's much more complete usercopy tests.
> >
> >  v3:
> >   - use MEMEQ KUnit helper (David)
> >   - exclude pathological address confusion test for systems with separate
> >     address spaces, noticed by David
> >   - add KUnit-conditional exports for alloc_mm() and arch_pick_mmap_layout()
> >     noticed by 0day
> >  v2: https://lore.kernel.org/lkml/20240610213055.it.075-kees@kernel.org/
> >  v1: https://lore.kernel.org/lkml/20240519190422.work.715-kees@kernel.org/
> >
> > -Kees
> >
> > [1] https://lore.kernel.org/lkml/20230321122514.1743889-2-mark.rutland@arm.com/
> 
> Thanks! This looks good to me (and passes everything here). Unless
> there's a compelling reason not to, I think we can take this via the
> KUnit tree.

That would be lovely, thank you! :)

-- 
Kees Cook