History

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.

Kees Cook committed 2 years ago

Commit 51104c11 parent 425ae3a5 files · +137 −0Browse files

Showing the changes to include/kunit (1 of 5 files). Show all

Unified · Split

include/kunit/test.h+17−0
@@ -480,6 +480,23 @@ static inline void *kunit_kcalloc(struct kunit *test, size_t n, size_t size, gfp · 479 unmodified lines
480480 return kunit_kmalloc_array(test, n, size, gfp | __GFP_ZERO);
481481 }
482482
483+/**
484+ * kunit_vm_mmap() - Allocate KUnit-tracked vm_mmap() area
485+ * @test: The test context object.
486+ * @file: struct file pointer to map from, if any
487+ * @addr: desired address, if any
488+ * @len: how many bytes to allocate
489+ * @prot: mmap PROT_* bits
490+ * @flag: mmap flags
491+ * @offset: offset into @file to start mapping from.
492+ *
493+ * See vm_mmap() for more information.
494+ */
495+unsigned long kunit_vm_mmap(struct kunit *test, struct file *file,
496+ unsigned long addr, unsigned long len,
497+ unsigned long prot, unsigned long flag,
498+ unsigned long offset);
499+
483500 void kunit_cleanup(struct kunit *test);
484501
485502 void __printf(2, 3) kunit_log_append(struct string_stream *log, const char *fmt, ...);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t