From 51104c19d8570eb23208e08eac0e9ae09ced1c15 Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Wed, 12 Jun 2024 12:59:18 -0700 Subject: kunit: test: Add vm_mmap() allocation resource manager 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@arm.com/ [1] Co-developed-by: Mark Rutland Signed-off-by: Mark Rutland Reviewed-by: David Gow Signed-off-by: Kees Cook Signed-off-by: Shuah Khan --- include/kunit/test.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'include/kunit/test.h') diff --git a/include/kunit/test.h b/include/kunit/test.h index e32b4cb7afa2..ec61cad6b71d 100644 --- a/include/kunit/test.h +++ b/include/kunit/test.h @@ -480,6 +480,23 @@ static inline void *kunit_kcalloc(struct kunit *test, size_t n, size_t size, gfp return kunit_kmalloc_array(test, n, size, gfp | __GFP_ZERO); } +/** + * kunit_vm_mmap() - Allocate KUnit-tracked vm_mmap() area + * @test: The test context object. + * @file: struct file pointer to map from, if any + * @addr: desired address, if any + * @len: how many bytes to allocate + * @prot: mmap PROT_* bits + * @flag: mmap flags + * @offset: offset into @file to start mapping from. + * + * See vm_mmap() for more information. + */ +unsigned long kunit_vm_mmap(struct kunit *test, struct file *file, + unsigned long addr, unsigned long len, + unsigned long prot, unsigned long flag, + unsigned long offset); + void kunit_cleanup(struct kunit *test); void __printf(2, 3) kunit_log_append(struct string_stream *log, const char *fmt, ...); -- cgit v1.2.3 '>
AgeCommit message (Expand)AuthorFilesLines
2025-07-28block: change blk_get_meta_cap() stub return -ENOIOCTLCMDKlara Modin1-1/+1
2025-07-28fuse: remove page alignment check for writeback lenJoanne Koong1-2/+0
2025-07-28i2c: core: Fix double-free of fwnode in i2c_unregister_device()Hans de Goede1-1/+7
2025-07-28MIPS: alchemy: gpio: use new GPIO line value setter callbacks for the remaini...Bartosz Golaszewski1-4/+8
2025-07-27Linux 6.16v6.16Linus Torvalds1-1/+1
2025-07-27gpiolib: enable CONFIG_GPIOLIB_LEGACY even for !GPIOLIBArnd Bergmann1-2/+2
2025-07-26sched/task_stack: Add missing const qualifier to end_of_stack()Kees Cook1-1/+1
2025-07-26kstack_erase: Support Clang stack depth trackingKees Cook2-1/+10
2025-07-26kstack_erase: Add -mgeneral-regs-only to silence Clang warningsKees Cook1-0/+1
2025-07-26init.h: Disable sanitizer coverage for __init and __headKees Cook2-2/+4
2025-07-26kstack_erase: Disable kstack_erase for all of arm compressed boot codeKees Cook1-1/+1
2025-07-25hfs: fix general protection fault in hfs_find_init()Viacheslav Dubeyko4-12/+51
2025-07-25hfs: fix slab-out-of-bounds in hfs_bnode_read()Viacheslav Dubeyko1-0/+92
2025-07-25hfsplus: fix slab-out-of-bounds in hfsplus_bnode_read()Viacheslav Dubeyko1-0/+92
2025-07-25hfsplus: fix slab-out-of-bounds read in hfsplus_uni2asc()Viacheslav Dubeyko1-0/+7
2025-07-25hfsplus: don't use BUG_ON() in hfsplus_create_attributes_file()Tetsuo Handa1-1/+5
2025-07-25hfsplus: don't set REQ_SYNC for hfsplus_submit_bio()Johannes Thumshirn1-4/+2
2025-07-25i2c: lpi2c: implement xfer_atomic callbackEmanuele Ghidoli1-38/+132
2025-07-25i2c: lpi2c: use readl_poll_timeout() for register pollingEmanuele Ghidoli1-49/+45
2025-07-25dt-bindings: i2c: i2c-rk3x: Allow use of a power-domainJonas Karlman1-0/+3
2025-07-25dt-bindings: i2c: exynos5: add samsung,exynos2200-hsi2c compatibleIvaylo Ivanov1-0/+1
2025-07-25i2c: lpi2c: convert to use secs_to_jiffies()Yuesong Li1-1/+1
2025-07-25i2c: st: Use min() to improve codeQianfeng Rong1-13/+6
2025-07-25dt-bindings: display: mediatek,dp: Allow DisplayPort AUX busAngeloGioacchino Del Regno1-0/+3
2025-07-25dt-bindings: fsl: convert fsl,vf610-mscm-ir.txt to yaml formatFrank Li2-30/+63