[LTP] lib: add module is loaded check

linuxtestproject.agent@gmail.com linuxtestproject.agent@gmail.com
Sat Oct 10 11:38:35 CEST 2026


Hi Li,

On 10 October 2026, Li Wang 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: The new public helper has no kernel-doc comment. Document mod_name,
hyphen normalization, return values, and whether built-in modules count
as loaded.

--- [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 modprobe fails, tst_modprobe() aborts before modules_loaded
becomes true, so cleanup skips modules already loaded successfully.
Track each successful load separately and make partial-load cleanup
available before invoking the next modprobe.

> +		const char *const argv[] = { "modprobe", "-r",
> +						loaded_modules[i - 1], NULL };

High: modprobe -r also removes unused dependencies, including modules
loaded before the test and excluded from this list. For example, removing
can-raw can remove a pre-existing can module; snapshot dependency ownership
and remove only modules loaded by this test.

> +		tst_cmd(argv, "/dev/null", "/dev/null", TST_CMD_PASS_RETVAL);
> +	}
> +
> +	loaded_module_count = 0;

Medium: Every removal error is discarded, both output streams are
suppressed, and the ownership list is then cleared. Keep teardown nonfatal,
but report failed removals with TWARN and the module name instead of
silently leaving new modules loaded.

--- [PATCH 3/4] ---

> diff --git a/testcases/cve/cve-2025-21756.c b/testcases/cve/cve-2025-21756.c
> +	.needs_root = 1,

Low: Document the new root requirement in the test description: root is
needed to load the VSOCK modules, while the reproducer runs as nobody.
The commit message explains this, but the exported test description does
not.

Verdict - Needs revision

Pre-existing issue (not a patch finding):

The description in testcases/cve/sctphantom.c says to run modprobe sctp
manually, although setup() already loaded it before this series.

---
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