[LTP] tst_kconfig: load and unload kernel modules for CONFIG_*=m

linuxtestproject.agent@gmail.com linuxtestproject.agent@gmail.com
Wed Oct 7 16:17:58 CEST 2026


Hi Li,

On Wed, 7 Oct 2026, Li Wang wrote:
> tst_kconfig: load and unload kernel modules for CONFIG_*=m

--- [PATCH 1/3] ---

> diff --git a/lib/tst_kconfig.c b/lib/tst_kconfig.c
> +	if (loaded_module_count < MAX_LOADED_MODULES)
> +		loaded_modules[loaded_module_count++] = mod;

High: This records config matches, not modules newly loaded by the test,
so cleanup can remove an unused module that was already loaded beforehand.
A read-only tst_kconfig_read() during a callback also adds unload targets
without loading them. Separate config discovery from ownership tracking
and unload only modules successfully added by this test.

> diff --git a/lib/tst_test.c b/lib/tst_test.c
> +	tst_kconfig_module_unload_all();

High: Loading happens once in the library parent, but this cleanup runs
in each test child. Setup aborts and killed children leak modules, later
variants can lose modules removed by the first child, and cve-2026-46331
cannot unload after dropping initial-user-namespace privileges. Move
unloading to parent do_cleanup(), after all variants and resource teardown.

> diff --git a/lib/tst_kconfig.c b/lib/tst_kconfig.c
> +		tst_modprobe(loaded_modules[i], NULL);
> +		const char *const argv[] = { "rmmod", loaded_modules[i - 1], NULL };

Medium: modprobe also inserts dependencies that this list never records;
with both initially absent, loading can-raw inserts can, but cleanup only
removes can-raw and leaves can loaded. Track newly inserted dependencies
relative to the initial module state and remove owned modules in
dependency order.

> diff --git a/include/tst_kconfig.h b/include/tst_kconfig.h
> +/*
> + * tst_kconfig_module_load() - Load kernel modules for CONFIG_*=m entries.

Low: Both new public API comments use /* rather than /** and are omitted
from the generated kernel-doc reference. Use kernel-doc comment openers
for both declarations.

--- [PATCH 2/3] ---

> Map CONFIG_VSOCKETS and CONFIG_VSOCKETS_LOOPBACK to their kernel
> modules (vsock, vsock_loopback).

Low: The body only restates the mappings and does not explain the new
config and privilege gates in cve-2025-21756. Explain the missing-loopback
bind failure and why the test now requires root.

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

Low: Document this new root requirement in the test's high-level
description, identifying module loading as the privileged operation.

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

> diff --git a/testcases/kernel/syscalls/keyctl/keyctl29.c b/testcases/kernel/syscalls/keyctl/keyctl29.c
> -	tst_modprobe("x509_key_parser", NULL);
> diff --git a/testcases/kernel/syscalls/keyctl/keyctl30.c b/testcases/kernel/syscalls/keyctl/keyctl30.c
> -	tst_modprobe("pkcs8_key_parser", NULL);

Medium: With KCONFIG_SKIP_CHECK=1, tst_kconfig_check() returns before
recording modules, leaving these removed loads without a replacement.
When parser modules are installed but unloaded, keyctl29/keyctl30 now
skip with EBADMSG instead of executing their checks. Preserve module
setup independently of config validation, or retain the explicit loads.

Verdict - Needs revision

Pre-existing issue (not introduced by this series):

Medium: sctphantom saves its SCTP sysctls in the test child's private
tst_sys_conf list, but only the library parent calls tst_sys_conf_restore()
and cannot see those saved values. Use parent-side .save_restore after
module loading, or explicitly restore them in the test child's cleanup.

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