From: linuxtestproject.agent@gmail.com
To: Li Wang <li.wang@linux.dev>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] lib: add module is loaded check
Date: Mon, 2 Nov 2026 08:26:57 +0000 [thread overview]
Message-ID: <20261102082657.3791-1-linuxtestproject.agent@gmail.com> (raw)
In-Reply-To: <20261102024328.115105-2-li.wang@linux.dev>
Hi Li,
On Mon Nov 2 10:43:25 2026 +0800, Li Wang (Hieco) <li.wang@linux.dev> wrote:
> lib: add module is loaded check
--- [PATCH 1/4] ---
> --- 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);
Add a kernel-doc comment (/** ... */) for tst_module_is_loaded() documenting
@mod_name and Return:.
--- [PATCH 2/4] ---
> +static void kconfig_module_record(struct tst_kconfig_var *var)
> +{
> + unsigned int i;
> + const char *mod = NULL;
> +
> + if (var->choice != 'm')
> + return;
> +
> + for (i = 0; config_module_maps[i].config; i++) {
> + if (!strcmp(config_module_maps[i].config, var->id)) {
> + mod = config_module_maps[i].module_name;
> + break;
> + }
> + }
> +
> + if (!mod)
> + return;
> +
> + if (tst_module_is_loaded(mod))
> + return;
> +
> + for (i = 0; i < loaded_module_count; i++) {
> + if (!strcmp(loaded_modules[i], mod))
> + return;
> + }
> +
> + if (loaded_module_count < MAX_LOADED_MODULES)
> + loaded_modules[loaded_module_count++] = mod;
> +}
Recording modules into loaded_modules[] inside kconfig_parse_line() happens
even when geteuid() != 0, when tst_kconfig_check() fails with TCONF (e.g.
CONFIG_X509_CERTIFICATE_PARSER=y on a =m kernel), or when tst_kconfig_read()
is called later during the test. Consequently, tst_kconfig_module_unload() in
do_cleanup() attempts to unload modules that were never loaded by
tst_kconfig_module_load(), and fails with EPERM (emitting a spurious TWARN)
when running unprivileged (such as vsock01). Only record modules in the
unload list when tst_kconfig_module_load() actually loads them.
> + default:
> + tst_res(TWARN, "Failed to unload module '%s'", name);
> + }
Use TWARN | TERRNO so the failure reason from delete_module() is printed.
--- [PATCH 3/4] ---
> static struct tst_test test = {
> + .needs_root = 1,
> + .setup = setup,
> .test_all = run,
Document why root is required (loading the vsock/vsock_loopback modules) in
the top-level /*\ ... */ test description block.
--- [PATCH 4/4] ---
> /*\
> * 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.
Remove the extra asterisk in "* * Requires root", which creates a malformed
reST bullet item. Also update .needs_kconfigs in keyctl23.c from
"CONFIG_X509_CERTIFICATE_PARSER=y" to "CONFIG_X509_CERTIFICATE_PARSER",
otherwise tst_kconfig_check() aborts with TCONF on =m kernels instead of
loading x509_key_parser.
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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2026-11-02 8:27 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 2:43 [LTP] [PATCH v6 0/4] tst_kconfig: automatic module load/unload for CONFIG_*=m Li Wang (Hieco)
2026-11-02 2:43 ` [LTP] [PATCH v6 1/4] lib: add module is loaded check Li Wang (Hieco)
2026-11-02 8:26 ` linuxtestproject.agent [this message]
2026-11-02 2:43 ` [LTP] [PATCH v6 2/4] tst_kconfig: load and unload kernel modules for CONFIG_*=m Li Wang (Hieco)
2026-11-02 2:43 ` [LTP] [PATCH v6 3/4] tst_kconfig: add module mappings for vsock/vsock_loopback Li Wang (Hieco)
2026-11-02 2:43 ` [LTP] [PATCH v6 4/4] testcases: drop manual tst_modprobe() now handled by tst_kconfig Li Wang (Hieco)
-- strict thread matches above, loose matches on Subject: below --
2026-11-03 7:57 [LTP] [PATCH v7 1/4] lib: add module is loaded check Li Wang (Hieco)
2026-11-03 10:19 ` [LTP] " linuxtestproject.agent
2026-10-15 7:58 [LTP] [PATCH v5 1/4] " Li Wang
2026-10-15 9:01 ` [LTP] " linuxtestproject.agent
2026-10-14 6:11 [LTP] [PATCH v4 1/4] " Li Wang
2026-10-14 7:41 ` [LTP] " linuxtestproject.agent
2026-10-10 3:36 [LTP] [PATCH v3 1/4] " Li Wang
2026-10-10 9:38 ` [LTP] " linuxtestproject.agent
2026-10-08 5:21 [LTP] [Patch v2 1/4] " Li Wang
2026-10-08 10:14 ` [LTP] " linuxtestproject.agent
2026-10-10 1:43 ` Li Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261102082657.3791-1-linuxtestproject.agent@gmail.com \
--to=linuxtestproject.agent@gmail.com \
--cc=li.wang@linux.dev \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.