[LTP] lib: add module is loaded check
linuxtestproject.agent@gmail.com
linuxtestproject.agent@gmail.com
Tue Nov 3 11:19:38 CET 2026
Hi Li,
On Mon Apr 13 15:25:17 2026 +0800, Li Wang <liwang@redhat.com> wrote:
> lib: add module is loaded check
--- [PATCH 1/4] ---
> diff --git a/include/tst_module.h b/include/tst_module.h
> index e55321d19..9b789e289 100644
> --- a/include/tst_module.h
> +++ b/include/tst_module.h
> @@ -49,5 +49,6 @@ static inline void tst_requires_module_signature_disabled(void)
>
> void tst_modprobe(const char *mod_name, char *const argv[]);
> void tst_module_reload(const char *mod_name, char *const argv[]);
> +bool tst_module_is_loaded(const char *mod_name);
New public library functions in include/ should have a kernel-doc
(/** ... */) comment describing @mod_name and Return:.
--- [PATCH 3/4] ---
> diff --git a/testcases/cve/cve-2025-21756.c b/testcases/cve/cve-2025-21756.c
> index 4245a4c95..b49950045 100644
> --- a/testcases/cve/cve-2025-21756.c
> +++ b/testcases/cve/cve-2025-21756.c
> @@ -85,8 +95,15 @@ static void run(void)
> }
>
> static struct tst_test test = {
> + .needs_root = 1,
> + .setup = setup,
The reason .needs_root = 1 is required (loading the vsock and
vsock_loopback modules before dropping privileges in setup()) should also
be documented in the test's /*\ ... */ doc comment.
--- [PATCH 4/4] ---
> 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]
> *
> @@ -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 still has "CONFIG_X509_CERTIFICATE_PARSER=y" in .needs_kconfigs
instead of "CONFIG_X509_CERTIFICATE_PARSER", so tst_kconfig_check() aborts
with TCONF when the option is =m before tst_kconfig_module_load() is
called, and never loads a module when it is =y. Drop =y from
"CONFIG_X509_CERTIFICATE_PARSER=y" in .needs_kconfigs (matching keyctl29.c)
so CONFIG_X509_CERTIFICATE_PARSER=m is accepted and x509_key_parser is
loaded automatically.
Verdict - Needs revision
Pre-existing issues:
- testcases/cve/sctphantom.c: the doc comment at lines 46-48 still says the
test reports TCONF if the sctp module is not loaded ("run modprobe sctp
first"), and the sysctls saved via tst_sys_conf_save() in setup() could
now use .save_restore in struct tst_test since do_setup() loads the module
before .save_restore and do_cleanup() unloads it after
tst_sys_conf_restore().
---
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