[LTP] lib: add module is loaded check

linuxtestproject.agent@gmail.com linuxtestproject.agent@gmail.com
Wed Nov 25 11:43:57 CET 2026


Hi Li,

On Wed Nov 25 11:05:26 2026 +0800, Li Wang (Hieco) <li.wang@linux.dev> wrote:
> lib: add module is loaded check

--- [PATCH 2/4] ---

> diff --git a/lib/tst_kconfig.c b/lib/tst_kconfig.c
> index f055c2e5f..8b4d0e2ef 100644
> --- a/lib/tst_kconfig.c
> +++ b/lib/tst_kconfig.c
> @@ -178,6 +186,12 @@ static void kconfig_module_check(struct tst_kconfig_var *var)
>  		if (strcmp(config_module_maps[i].config, var->id))
>  			continue;
>  
> +		if (strchr(config_module_maps[i].module_name, '-')) {
> +			tst_brk(TBROK, "config_module_maps[]: module '%s' "
> +					"must use '_' instead of '-'",
> +					config_module_maps[i].module_name);
> +		}

config_module_maps[] still contains {"CONFIG_CAN_RAW", "can-raw"} and
{"CONFIG_CAN_BCM", "can-bcm"} with hyphens. When either option is set to =m,
tests listing CONFIG_CAN_RAW or CONFIG_CAN_BCM in .needs_kconfigs (such as
can_filter, can_rcv_own_msgs, and can_bcm01) will now abort with TBROK here.
Update those two entries in config_module_maps[] to "can_raw" and "can_bcm".

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

> diff --git a/testcases/cve/sctphantom.c b/testcases/cve/sctphantom.c
> index 83834b848..bdbe40286 100644
> --- a/testcases/cve/sctphantom.c
> +++ b/testcases/cve/sctphantom.c
> @@ -205,8 +204,6 @@ static void setup(void)
>  	};
>  	const struct tst_path_val *sysctl;
>  
> -	tst_modprobe("sctp", NULL);
> -
>  	for (sysctl = sysctls; sysctl->path; sysctl++)
>  		tst_sys_conf_save(sysctl);

Now that the sctp module is loaded in do_setup() before .save_restore is
processed, move sysctls[] to .save_restore in struct tst_test; calling
tst_sys_conf_save() inside setup() runs in the forked test child process, so
do_cleanup() in the library process never restores those sysctls if sctp was
already loaded. Also update the top-level doc comment in sctphantom.c, which
still instructs the user to run "modprobe sctp" first.

> diff --git a/testcases/kernel/syscalls/keyctl/keyctl23.c b/testcases/kernel/syscalls/keyctl/keyctl23.c
> index cf90210d2..adfb1197a 100644
> --- a/testcases/kernel/syscalls/keyctl/keyctl23.c
> +++ b/testcases/kernel/syscalls/keyctl/keyctl23.c
> @@ -6,7 +6,8 @@
>  /*\
>   * Test ``KEYCTL_RESTRICT_KEYRING`` builtin_trusted of :manpage:`keyctl(2)`.
>   *
> - * Requires root (CAP_SYS_MODULE) to load the ``x509_key_parser`` module.
> + * Requires root (CAP_SYS_MODULE) so that the test library can load the
> + * ``x509_key_parser`` module.
>   *
>   * [Algorithm]
>   *
> @@ -16,7 +17,6 @@
>   */
>  
>  #include "keyctl_common.h"
> -#include "tst_module.h"
>  
>  #define PAYLOAD		"payload"
>  
> @@ -89,8 +89,6 @@ static void setup(void)
>  {
>  	SAFE_KEYCTL(KEYCTL_JOIN_SESSION_KEYRING, 0, 0, 0, 0);
>  
> -	tst_modprobe("x509_key_parser", NULL);
> -
>  	ring_builtin = SAFE_NEW_RING("ltpkeyctl23_builtin");

keyctl23.c sets "CONFIG_X509_CERTIFICATE_PARSER=y" in .needs_kconfigs, which
rejects CONFIG_X509_CERTIFICATE_PARSER=m with TCONF before
tst_kconfig_module_load() is reached. Change the entry in .needs_kconfigs to
"CONFIG_X509_CERTIFICATE_PARSER" so modular x509_key_parser is accepted and
loaded, or drop .needs_root = 1 and the x509_key_parser module comment if =y
is required.

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