diff options
author | Kees Cook <kees@kernel.org> | 2024-05-20 03:17:59 +0300 |
---|---|---|
committer | Kees Cook <kees@kernel.org> | 2024-06-19 23:13:55 +0300 |
commit | 60371f43e56bfad1f438621fae286e1de5bb6877 (patch) | |
tree | 32dea290ec0851b4a59732c449c5a685e59c1884 /fs/exec.c | |
parent | 3545deff0ec7a37de7ed9632e262598582b140e9 (diff) | |
download | linux-60371f43e56bfad1f438621fae286e1de5bb6877.tar.xz |
exec: Add KUnit test for bprm_stack_limits()
Since bprm_stack_limits() operates with very limited side-effects, add
it as the first exec.c KUnit test. Add to Kconfig and adjust MAINTAINERS
file to include it.
Tested on 64-bit UML:
$ tools/testing/kunit/kunit.py run exec
Link: https://lore.kernel.org/lkml/20240520021615.741800-1-keescook@chromium.org/
Signed-off-by: Kees Cook <kees@kernel.org>
Diffstat (limited to 'fs/exec.c')
-rw-r--r-- | fs/exec.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/fs/exec.c b/fs/exec.c index 40073142288f..c3bec126505b 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -486,6 +486,15 @@ static int count_strings_kernel(const char *const *argv) return i; } +/* + * Calculate bprm->argmin from: + * - _STK_LIM + * - ARG_MAX + * - bprm->rlim_stack.rlim_cur + * - bprm->argc + * - bprm->envc + * - bprm->p + */ static int bprm_stack_limits(struct linux_binprm *bprm) { unsigned long limit, ptr_size; @@ -2211,3 +2220,7 @@ static int __init init_fs_exec_sysctls(void) fs_initcall(init_fs_exec_sysctls); #endif /* CONFIG_SYSCTL */ + +#ifdef CONFIG_EXEC_KUNIT_TEST +#include "exec_test.c" +#endif |