[LTP] lib: add module is loaded check
linuxtestproject.agent@gmail.com
linuxtestproject.agent@gmail.com
Wed Oct 14 09:41:38 CEST 2026
Hi Li,
On 14 October 2026, Li Wang (Hieco) wrote:
> [PATCH 1/4] 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 API, including mod_name,
hyphen normalization, the return value, and how an unreadable
/proc/modules is handled.
--- [PATCH 2/4] ---
> diff --git a/lib/tst_kconfig.c b/lib/tst_kconfig.c
> + tst_modprobe(loaded_modules[i], NULL);
> + }
> +
> + modules_loaded = true;
Medium: If one module loads and a later modprobe fails, cleanup sees
modules_loaded == false and leaves the successfully loaded module behind.
Track successful loads incrementally so cleanup also handles partial
failure.
> + const char *const argv[] = { "modprobe", "-r",
> + loaded_modules[i - 1], NULL };
High: modprobe -r also removes unused dependencies, including modules
that were loaded before the test; for example, removing can-raw can
also remove a pre-existing can module.
Snapshot the initial module state and unload only modules introduced
by the test, rather than recursively removing untracked dependencies.
--- [PATCH 3/4] ---
> diff --git a/testcases/cve/cve-2025-21756.c b/testcases/cve/cve-2025-21756.c
> +static void restore_privileges(void)
> +{
> + SAFE_SETEGID(0);
> + SAFE_SETEUID(0);
> +}
Medium: When root starts with nonzero real/saved group IDs, setegid(0)
fails with permission denied after setup drops the effective uid, adding
a cleanup warning to an otherwise passing test.
Restore the effective uid first and restore the original effective gid,
not an assumed gid of 0.
Alternatively, omit this restoration: module unloading runs in the
still-root framework parent, not this test child.
> + .needs_root = 1,
Low: Document the new root requirement in the test description: root
loads the modules, then the reproducer drops effective privileges.
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