fs/tests/exec_kunit.c
Source file repositories/reference/linux-study-clean/fs/tests/exec_kunit.c
File Facts
- System
- Linux kernel
- Corpus path
fs/tests/exec_kunit.c- Extension
.c- Size
- 6182 bytes
- Lines
- 133
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
kunit/test.h
Detected Declarations
struct bprm_stack_limits_resultfunction exec_test_bprm_stack_limits
Annotated Snippet
struct bprm_stack_limits_result {
struct linux_binprm bprm;
int expected_rc;
unsigned long expected_argmin;
};
static const struct bprm_stack_limits_result bprm_stack_limits_results[] = {
/* Negative argc/envc counts produce -E2BIG */
{ { .p = ULONG_MAX, .rlim_stack.rlim_cur = ULONG_MAX,
.argc = INT_MIN, .envc = INT_MIN }, .expected_rc = -E2BIG },
{ { .p = ULONG_MAX, .rlim_stack.rlim_cur = ULONG_MAX,
.argc = 5, .envc = -1 }, .expected_rc = -E2BIG },
{ { .p = ULONG_MAX, .rlim_stack.rlim_cur = ULONG_MAX,
.argc = -1, .envc = 10 }, .expected_rc = -E2BIG },
/* The max value of argc or envc is MAX_ARG_STRINGS. */
{ { .p = ULONG_MAX, .rlim_stack.rlim_cur = ULONG_MAX,
.argc = INT_MAX, .envc = INT_MAX }, .expected_rc = -E2BIG },
{ { .p = ULONG_MAX, .rlim_stack.rlim_cur = ULONG_MAX,
.argc = MAX_ARG_STRINGS, .envc = MAX_ARG_STRINGS }, .expected_rc = -E2BIG },
{ { .p = ULONG_MAX, .rlim_stack.rlim_cur = ULONG_MAX,
.argc = 0, .envc = MAX_ARG_STRINGS }, .expected_rc = -E2BIG },
{ { .p = ULONG_MAX, .rlim_stack.rlim_cur = ULONG_MAX,
.argc = MAX_ARG_STRINGS, .envc = 0 }, .expected_rc = -E2BIG },
/*
* On 32-bit system these argc and envc counts, while likely impossible
* to represent within the associated TASK_SIZE, could overflow the
* limit calculation, and bypass the ptr_size <= limit check.
*/
{ { .p = ULONG_MAX, .rlim_stack.rlim_cur = ULONG_MAX,
.argc = 0x20000001, .envc = 0x20000001 }, .expected_rc = -E2BIG },
#ifdef CONFIG_MMU
/* Make sure a pathological bprm->p doesn't cause an overflow. */
{ { .p = sizeof(void *), .rlim_stack.rlim_cur = ULONG_MAX,
.argc = 10, .envc = 10 }, .expected_rc = -E2BIG },
#endif
/*
* 0 rlim_stack will get raised to ARG_MAX. With 1 string pointer,
* we should see p - ARG_MAX + sizeof(void *).
*/
{ { .p = ULONG_MAX, .rlim_stack.rlim_cur = 0,
.argc = 1, .envc = 0 }, .expected_argmin = ULONG_MAX - ARG_MAX + sizeof(void *)},
/* Validate that argc is always raised to a minimum of 1. */
{ { .p = ULONG_MAX, .rlim_stack.rlim_cur = 0,
.argc = 0, .envc = 0 }, .expected_argmin = ULONG_MAX - ARG_MAX + sizeof(void *)},
/*
* 0 rlim_stack will get raised to ARG_MAX. With pointers filling ARG_MAX,
* we should see -E2BIG. (Note argc is always raised to at least 1.)
*/
{ { .p = ULONG_MAX, .rlim_stack.rlim_cur = 0,
.argc = ARG_MAX / sizeof(void *), .envc = 0 }, .expected_rc = -E2BIG },
{ { .p = ULONG_MAX, .rlim_stack.rlim_cur = 0,
.argc = 0, .envc = ARG_MAX / sizeof(void *) - 1 }, .expected_rc = -E2BIG },
{ { .p = ULONG_MAX, .rlim_stack.rlim_cur = 0,
.argc = ARG_MAX / sizeof(void *) + 1, .envc = 0 }, .expected_rc = -E2BIG },
{ { .p = ULONG_MAX, .rlim_stack.rlim_cur = 0,
.argc = 0, .envc = ARG_MAX / sizeof(void *) }, .expected_rc = -E2BIG },
/* And with one less, we see space for exactly 1 pointer. */
{ { .p = ULONG_MAX, .rlim_stack.rlim_cur = 0,
.argc = (ARG_MAX / sizeof(void *)) - 1, .envc = 0 },
.expected_argmin = ULONG_MAX - sizeof(void *) },
{ { .p = ULONG_MAX, .rlim_stack.rlim_cur = 0,
.argc = 0, .envc = (ARG_MAX / sizeof(void *)) - 2, },
.expected_argmin = ULONG_MAX - sizeof(void *) },
/* If we raise rlim_stack / 4 to exactly ARG_MAX, nothing changes. */
{ { .p = ULONG_MAX, .rlim_stack.rlim_cur = ARG_MAX * 4,
.argc = ARG_MAX / sizeof(void *), .envc = 0 }, .expected_rc = -E2BIG },
{ { .p = ULONG_MAX, .rlim_stack.rlim_cur = ARG_MAX * 4,
.argc = 0, .envc = ARG_MAX / sizeof(void *) - 1 }, .expected_rc = -E2BIG },
{ { .p = ULONG_MAX, .rlim_stack.rlim_cur = ARG_MAX * 4,
.argc = ARG_MAX / sizeof(void *) + 1, .envc = 0 }, .expected_rc = -E2BIG },
{ { .p = ULONG_MAX, .rlim_stack.rlim_cur = ARG_MAX * 4,
.argc = 0, .envc = ARG_MAX / sizeof(void *) }, .expected_rc = -E2BIG },
{ { .p = ULONG_MAX, .rlim_stack.rlim_cur = ARG_MAX * 4,
.argc = (ARG_MAX / sizeof(void *)) - 1, .envc = 0 },
.expected_argmin = ULONG_MAX - sizeof(void *) },
{ { .p = ULONG_MAX, .rlim_stack.rlim_cur = ARG_MAX * 4,
.argc = 0, .envc = (ARG_MAX / sizeof(void *)) - 2, },
.expected_argmin = ULONG_MAX - sizeof(void *) },
/* But raising it another pointer * 4 will provide space for 1 more pointer. */
{ { .p = ULONG_MAX, .rlim_stack.rlim_cur = (ARG_MAX + sizeof(void *)) * 4,
.argc = ARG_MAX / sizeof(void *), .envc = 0 },
.expected_argmin = ULONG_MAX - sizeof(void *) },
{ { .p = ULONG_MAX, .rlim_stack.rlim_cur = (ARG_MAX + sizeof(void *)) * 4,
.argc = 0, .envc = ARG_MAX / sizeof(void *) - 1 },
.expected_argmin = ULONG_MAX - sizeof(void *) },
/* Raising rlim_stack / 4 to _STK_LIM / 4 * 3 will see more space. */
{ { .p = ULONG_MAX, .rlim_stack.rlim_cur = 4 * (_STK_LIM / 4 * 3),
.argc = 0, .envc = 0 },
.expected_argmin = ULONG_MAX - (_STK_LIM / 4 * 3) + sizeof(void *) },
/* But raising it any further will see no increase. */
Annotation
- Immediate include surface: `kunit/test.h`.
- Detected declarations: `struct bprm_stack_limits_result`, `function exec_test_bprm_stack_limits`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.