Bug 212205
Summary: | KASAN: port all tests to KUnit | ||
---|---|---|---|
Product: | Memory Management | Reporter: | Andrey Konovalov (andreyknvl) |
Component: | Sanitizers | Assignee: | MM/Sanitizers virtual assignee (mm_sanitizers) |
Status: | RESOLVED CODE_FIX | ||
Severity: | normal | CC: | kasan-dev, snovitoll |
Priority: | P1 | ||
Hardware: | All | ||
OS: | Linux | ||
Kernel Version: | upstream | Subsystem: | |
Regression: | No | Bisected commit-id: |
Description
Andrey Konovalov
2021-03-09 16:37:40 UTC
Some options for #3: - Spawning a user task from the kernel. - Creating fake mm structs. - Using kernel memory as arguments to copy_to/from_user. (It might make sense to add tests for this in either case.) Note: currently, lib/kasan_test_module.c doesn't work with HW_TAGS KASAN. When the tests are ported to KUnit, they should be explicitly checked with that KASAN mode. Posted patches porting #1 and #2 to KUnit [1]. For #3, another potential approach is to hijack a userspace process via tracepoints, and execute the test there. However, this can only be done when userspace processes are launched (=> when KUnit tests are loaded as a module) and also requires the faultable tracepoints patchset [2]. [1] https://lore.kernel.org/linux-mm/653d43e9a6d9aad2ae148a941dab048cb8e765a8.1664044241.git.andreyknvl@google.com/T/ [2] https://lore.kernel.org/bpf/20210218222125.46565-5-mjeanson@efficios.com/T/ Non-copy_to/from_user tests have been ported to KUnit in [1] and [2]. For copy_to/from_user tests, we could keep them in a module, but nevertheless integrate with KUnit. This won't allow easily running them during boot, but other approaches seem overly complicated to implement. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b2c5bd4c69ce28500ed2176d11002a4e9b30da36 [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8516e837cab0b2c740b90603b66039aa7dcecda4 KUnit now supports creating mock userspace memory mappings via kunit_vm_mmap, so we should be able to port all tests to KUnit. See lib/usercopy_kunit.c as a reference. Hello, I've made a patch for #3. https://lore.kernel.org/linux-mm/20241011071657.3032690-1-snovitoll@gmail.com/T/#u Resolved by Sabyrzhan in [1]. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ca79a00bb9a899674a63018c6cd155a3730c3509 |