[LTP] lib: add module is loaded check
linuxtestproject.agent@gmail.com
linuxtestproject.agent@gmail.com
Thu Oct 15 11:01:47 CEST 2026
Hi Li,
On 15 October 2026, Li Wang (Hieco) wrote:
> lib: add module is loaded check
--- [PATCH 1/4] ---
> diff --git a/include/tst_module.h b/include/tst_module.h
> +bool tst_module_is_loaded(const char *mod_name);
Low: Add kernel-doc for this new public helper, documenting mod_name,
hyphen/underscore normalization, and its return semantics, including
built-in modules and failure to open /proc/modules.
--- [PATCH 2/4] ---
> diff --git a/lib/tst_kconfig.c b/lib/tst_kconfig.c
> + for (i = 0; i < loaded_module_count; i++) {
> + tst_res(TDEBUG, "Loading module '%s'", loaded_modules[i]);
> + tst_modprobe(loaded_modules[i], NULL);
> + }
> +
> + modules_loaded = true;
High: If a later tst_modprobe() aborts, modules_loaded is still false, so
do_cleanup() skips unloading earlier successfully loaded modules. Track
successful loads incrementally and make that prefix eligible for cleanup
before attempting the next load.
> + const char *const argv[] = { "modprobe", "-r",
> + loaded_modules[i - 1], NULL };
High: modprobe -r also removes unused dependencies, including pre-existing
ones: if can is already loaded and this run loads can-raw, cleanup can
remove both. Track ownership of dependencies and use targeted removal so
cleanup preserves modules that were loaded before the test.
> diff --git a/include/tst_kconfig.h b/include/tst_kconfig.h
> + * Called from do_test_cleanup() so that the modules are released when
Low: The call is in do_cleanup() in the library parent, not
do_test_cleanup() in the test child. Correct this comment and the same
statement in the commit message.
--- [PATCH 3/4] ---
> diff --git a/testcases/cve/cve-2025-21756.c b/testcases/cve/cve-2025-21756.c
> + .needs_root = 1,
> + .setup = setup,
Low: Document the new root requirement in the test's description block:
root preloads the vsock modules, then setup drops privileges before running
the reproducer.
--- [PATCH 4/4] ---
> diff --git a/testcases/kernel/syscalls/keyctl/keyctl23.c b/testcases/kernel/syscalls/keyctl/keyctl23.c
> - * Requires root (CAP_SYS_MODULE) to load the ``x509_key_parser`` module.
> - *
Low: Remove keyctl23's remaining .needs_root = 1 alongside this explanation
and the load call. Its CONFIG_X509_CERTIFICATE_PARSER=y requirement means
the automatic loader has no parser module to load, and the remaining
operations act on the caller's own keyrings.
> All four tests already declare the matching configs in
Low: The list and diff contain five tests, not four.
Verdict - Needs revision
---
Note:
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
More information about the ltp
mailing list