* Re: [LTP] lib: add module is loaded check
2026-10-08 5:21 [LTP] [Patch v2 1/4] " Li Wang
@ 2026-10-08 10:14 ` linuxtestproject.agent
2026-10-10 1:43 ` Li Wang
0 siblings, 1 reply; 19+ messages in thread
From: linuxtestproject.agent @ 2026-10-08 10:14 UTC (permalink / raw)
To: Li Wang; +Cc: ltp
Hi Li,
On Thu, 8 Oct 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: Add kernel-doc for this new public API, including mod_name and the
return value. Document normalization, built-in modules, and the current
false return when /proc/modules cannot be read.
--- [PATCH 2/4] ---
> diff --git a/include/tst_kconfig.h b/include/tst_kconfig.h
> + * Called from do_test_cleanup() so that the modules are released when
> + * the test finishes, regardless of the test result.
Low: The actual caller is do_cleanup(), in the library parent process,
not do_test_cleanup(), which invokes the test's cleanup callback.
Correct the lifecycle description.
> diff --git a/lib/tst_kconfig.c b/lib/tst_kconfig.c
> +#define MAX_LOADED_MODULES 16
> + if (loaded_module_count < MAX_LOADED_MODULES)
> + loaded_modules[loaded_module_count++] = mod;
Medium: This commit already has 19 mappings, so a valid requirement list
with all 19 available as modules passes the config check but queues only
16, silently omitting three required loads. Size the storage from the
mapping table or allocate enough space instead of discarding entries.
> kconfig_module_check(&vars[i]);
> + kconfig_module_record(vars[i].id);
Medium: kconfig_module_check() can change choice to 'n' for an uninstalled
module, but this still queues it. For CONFIG_MMU | CONFIG_CAN_RAW with
MMU=y and an uninstalled CAN_RAW=m, the expression succeeds, then loading
can-raw aborts the otherwise runnable test. Queue only configs that
remain enabled after checking, without making optional branches mandatory.
> + 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 one modprobe succeeds and a later one aborts, modules_loaded is
still false, so the cleanup helper returns without unloading the earlier
module. Track each successful load immediately and let abort cleanup
unload that successful prefix, not unattempted entries.
> + const char *const argv[] = { "rmmod", loaded_modules[i - 1], NULL };
> + tst_cmd(argv, "/dev/null", "/dev/null", TST_CMD_PASS_RETVAL);
Medium: modprobe also inserts dependencies, but this removes only the
explicitly recorded names. With CONFIG_CAN=m and CONFIG_CAN_RAW=m,
loading can-raw also loads can; removing can-raw leaves the newly loaded,
unused can module behind. Track newly loaded dependencies and remove
only test-owned modules in dependency order.
--- [PATCH 3/4] ---
> The test also needs root to load the modules and to run as the
> vsock_loopback transport is not available from an unprivileged user
> namespace.
> diff --git a/testcases/cve/cve-2025-21756.c b/testcases/cve/cve-2025-21756.c
> + .needs_root = 1,
Low: Root is needed for module insertion, but loopback VSOCK on
nonprivileged ports in the initial namespaces does not require root;
an ordinary nonroot process is not an unprivileged user namespace.
Correct the commit message and document the loading-only requirement in
the test description. Drop privileges for the reproducer after the
framework has loaded the modules.
Verdict - Needs revision
Pre-existing issue: sctphantom's description requests manual module
preloading, although its setup already loaded sctp 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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [LTP] lib: add module is loaded check
2026-10-08 10:14 ` [LTP] " linuxtestproject.agent
@ 2026-10-10 1:43 ` Li Wang
0 siblings, 0 replies; 19+ messages in thread
From: Li Wang @ 2026-10-10 1:43 UTC (permalink / raw)
To: linuxtestproject.agent; +Cc: ltp
linuxtestproject.agent@gmail.com wrote:
> --- [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: Add kernel-doc for this new public API, including mod_name and the
> return value. Document normalization, built-in modules, and the current
> false return when /proc/modules cannot be read.
No need, funtion name is clear enough.
> --- [PATCH 2/4] ---
>
> > diff --git a/include/tst_kconfig.h b/include/tst_kconfig.h
> > + * Called from do_test_cleanup() so that the modules are released when
> > + * the test finishes, regardless of the test result.
>
> Low: The actual caller is do_cleanup(), in the library parent process,
> not do_test_cleanup(), which invokes the test's cleanup callback.
> Correct the lifecycle description.
No. We would do the unload in the lib-cleanup but not test_cleanup.
> > diff --git a/lib/tst_kconfig.c b/lib/tst_kconfig.c
> > +#define MAX_LOADED_MODULES 16
> > + if (loaded_module_count < MAX_LOADED_MODULES)
> > + loaded_modules[loaded_module_count++] = mod;
>
> Medium: This commit already has 19 mappings, so a valid requirement list
> with all 19 available as modules passes the config check but queues only
> 16, silently omitting three required loads. Size the storage from the
> mapping table or allocate enough space instead of discarding entries.
True in theory, but rarely happens in practice. In LTP tests, I haven't
seen any test load more than 16 modules.
But to be on safe side, let's use 32.
> > kconfig_module_check(&vars[i]);
> > + kconfig_module_record(vars[i].id);
>
> Medium: kconfig_module_check() can change choice to 'n' for an uninstalled
> module, but this still queues it. For CONFIG_MMU | CONFIG_CAN_RAW with
> MMU=y and an uninstalled CAN_RAW=m, the expression succeeds, then loading
> can-raw aborts the otherwise runnable test. Queue only configs that
> remain enabled after checking, without making optional branches mandatory.
Good point, let's adding back v1 check:
kconfig_runtime_check(&vars[i]);
kconfig_module_check(&vars[i]);
+ if (vars[i].choice == 'm')
+ kconfig_module_record(vars[i].id);
> > + 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 one modprobe succeeds and a later one aborts, modules_loaded is
> still false, so the cleanup helper returns without unloading the earlier
> module. Track each successful load immediately and let abort cleanup
> unload that successful prefix, not unattempted entries.
No. tst_modprobe() never calls tst_brk() internally, so a failed load
doesn't trigger the abort path at all, execution just continues.
> > + const char *const argv[] = { "rmmod", loaded_modules[i - 1], NULL };
> > + tst_cmd(argv, "/dev/null", "/dev/null", TST_CMD_PASS_RETVAL);
>
> Medium: modprobe also inserts dependencies, but this removes only the
> explicitly recorded names. With CONFIG_CAN=m and CONFIG_CAN_RAW=m,
> loading can-raw also loads can; removing can-raw leaves the newly loaded,
> unused can module behind. Track newly loaded dependencies and remove
> only test-owned modules in dependency order.
Ok, maybe we can consider `modprobe -r`.
> --- [PATCH 3/4] ---
>
> > The test also needs root to load the modules and to run as the
> > vsock_loopback transport is not available from an unprivileged user
> > namespace.
> > diff --git a/testcases/cve/cve-2025-21756.c b/testcases/cve/cve-2025-21756.c
> > + .needs_root = 1,
>
> Low: Root is needed for module insertion, but loopback VSOCK on
> nonprivileged ports in the initial namespaces does not require root;
> an ordinary nonroot process is not an unprivileged user namespace.
> Correct the commit message and document the loading-only requirement in
> the test description. Drop privileges for the reproducer after the
> framework has loaded the modules.
Ok.
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [LTP] lib: add module is loaded check
2026-10-10 3:36 [LTP] [PATCH v3 1/4] " Li Wang
@ 2026-10-10 9:38 ` linuxtestproject.agent
0 siblings, 0 replies; 19+ messages in thread
From: linuxtestproject.agent @ 2026-10-10 9:38 UTC (permalink / raw)
To: Li Wang; +Cc: ltp
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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [LTP] lib: add module is loaded check
2026-10-14 6:11 [LTP] [PATCH v4 1/4] " Li Wang
@ 2026-10-14 7:41 ` linuxtestproject.agent
0 siblings, 0 replies; 19+ messages in thread
From: linuxtestproject.agent @ 2026-10-14 7:41 UTC (permalink / raw)
To: Li Wang; +Cc: ltp
Hi Li,
On 14 October 2026, Li Wang (Hieco) wrote:
> [PATCH 1/4] 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: Add kernel-doc for this new public API, including mod_name,
hyphen normalization, the return value, and how an unreadable
/proc/modules is handled.
--- [PATCH 2/4] ---
> diff --git a/lib/tst_kconfig.c b/lib/tst_kconfig.c
> + tst_modprobe(loaded_modules[i], NULL);
> + }
> +
> + modules_loaded = true;
Medium: If one module loads and a later modprobe fails, cleanup sees
modules_loaded == false and leaves the successfully loaded module behind.
Track successful loads incrementally so cleanup also handles partial
failure.
> + const char *const argv[] = { "modprobe", "-r",
> + loaded_modules[i - 1], NULL };
High: modprobe -r also removes unused dependencies, including modules
that were loaded before the test; for example, removing can-raw can
also remove a pre-existing can module.
Snapshot the initial module state and unload only modules introduced
by the test, rather than recursively removing untracked dependencies.
--- [PATCH 3/4] ---
> diff --git a/testcases/cve/cve-2025-21756.c b/testcases/cve/cve-2025-21756.c
> +static void restore_privileges(void)
> +{
> + SAFE_SETEGID(0);
> + SAFE_SETEUID(0);
> +}
Medium: When root starts with nonzero real/saved group IDs, setegid(0)
fails with permission denied after setup drops the effective uid, adding
a cleanup warning to an otherwise passing test.
Restore the effective uid first and restore the original effective gid,
not an assumed gid of 0.
Alternatively, omit this restoration: module unloading runs in the
still-root framework parent, not this test child.
> + .needs_root = 1,
Low: Document the new root requirement in the test description: root
loads the modules, then the reproducer drops effective privileges.
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
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [LTP] lib: add module is loaded check
2026-10-15 7:58 [LTP] [PATCH v5 1/4] " Li Wang
@ 2026-10-15 9:01 ` linuxtestproject.agent
0 siblings, 0 replies; 19+ messages in thread
From: linuxtestproject.agent @ 2026-10-15 9:01 UTC (permalink / raw)
To: Li Wang; +Cc: ltp
Hi Li,
On 15 October 2026, Li Wang (Hieco) 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: Add kernel-doc for this new public helper, documenting mod_name,
hyphen/underscore normalization, and its return semantics, including
built-in modules and failure to open /proc/modules.
--- [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 tst_modprobe() aborts, modules_loaded is still false, so
do_cleanup() skips unloading earlier successfully loaded modules. Track
successful loads incrementally and make that prefix eligible for cleanup
before attempting the next load.
> + const char *const argv[] = { "modprobe", "-r",
> + loaded_modules[i - 1], NULL };
High: modprobe -r also removes unused dependencies, including pre-existing
ones: if can is already loaded and this run loads can-raw, cleanup can
remove both. Track ownership of dependencies and use targeted removal so
cleanup preserves modules that were loaded before the test.
> diff --git a/include/tst_kconfig.h b/include/tst_kconfig.h
> + * Called from do_test_cleanup() so that the modules are released when
Low: The call is in do_cleanup() in the library parent, not
do_test_cleanup() in the test child. Correct this comment and the same
statement in the commit message.
--- [PATCH 3/4] ---
> diff --git a/testcases/cve/cve-2025-21756.c b/testcases/cve/cve-2025-21756.c
> + .needs_root = 1,
> + .setup = setup,
Low: Document the new root requirement in the test's description block:
root preloads the vsock modules, then setup drops privileges before running
the reproducer.
--- [PATCH 4/4] ---
> diff --git a/testcases/kernel/syscalls/keyctl/keyctl23.c b/testcases/kernel/syscalls/keyctl/keyctl23.c
> - * Requires root (CAP_SYS_MODULE) to load the ``x509_key_parser`` module.
> - *
Low: Remove keyctl23's remaining .needs_root = 1 alongside this explanation
and the load call. Its CONFIG_X509_CERTIFICATE_PARSER=y requirement means
the automatic loader has no parser module to load, and the remaining
operations act on the caller's own keyrings.
> All four tests already declare the matching configs in
Low: The list and diff contain five tests, not four.
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
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [LTP] lib: add module is loaded check
2026-11-02 2:43 [LTP] [PATCH v6 1/4] " Li Wang (Hieco)
@ 2026-11-02 8:26 ` linuxtestproject.agent
0 siblings, 0 replies; 19+ messages in thread
From: linuxtestproject.agent @ 2026-11-02 8:26 UTC (permalink / raw)
To: Li Wang; +Cc: ltp
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
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [LTP] lib: add module is loaded check
2026-11-03 7:57 [LTP] [PATCH v7 1/4] lib: add module is loaded check Li Wang (Hieco)
@ 2026-11-03 10:19 ` linuxtestproject.agent
0 siblings, 0 replies; 19+ messages in thread
From: linuxtestproject.agent @ 2026-11-03 10:19 UTC (permalink / raw)
To: Li Wang; +Cc: ltp
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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 19+ messages in thread
* [LTP] [PATCH v8 0/4] tst_kconfig: automatic module load/unload for CONFIG_*=m
@ 2026-11-25 3:05 Li Wang (Hieco)
2026-11-25 3:05 ` [LTP] [PATCH v8 1/4] lib: add module is loaded check Li Wang (Hieco)
` (3 more replies)
0 siblings, 4 replies; 19+ messages in thread
From: Li Wang (Hieco) @ 2026-11-25 3:05 UTC (permalink / raw)
To: chrubis, wakel; +Cc: ltp
Tests that depend on a config set to =m currently load the module
themselves, and may fail with misleading errors when it is missing,
e.g. bind() returning EADDRNOTAVAIL for AF_VSOCK without vsock_loopback.
This series makes tst_kconfig record the module for every
config_module_maps[] entry seen as =m, load them once the kernel
config check passes, and unload them at cleanup time.
Changes in v8:
- Enforce '_' in config_module_maps[] module names (suggested by Cyril)
- Drop the '-' -> '_' conversion and the name copy in tst_kconfig_module_unload()
Changes in v7:
- Split module_count and loaded_module_count: the former is the number
of recorded modules, the latter the number successfully loaded.
- Add TERRNO to the TWARN message in tst_kconfig_module_unload().
- Fix the malformed reST bullet "* * Requires root" in keyctl23.c.
Changes in v6:
- Rename tst_kconfig_module_unload_all to tst_kconfig_module_unload.
- Unload modules with delete_module(O_NONBLOCK) instead of tst_modprobe().
- Drop the redundant modules_loaded flag.
- Reword keyctl23 root note instead of removing it.
Changes in v5:
- cve-2025-21756.c: merge drop_privileges into setup and drop cleanup.
- keyctl23.c: remove tst_modprobe() so it can run on Android.
Changes in v4:
- tst_kconfig: fold module_name_for_config() into
kconfig_module_record()
- tst_kconfig: move the choice == 'm' gate into
kconfig_module_record() and pass struct tst_kconfig_var * instead
of the raw config name.
Changes in v3:
- Queue only configs that stay 'm' after kconfig_module_check(),
so a module downgraded to 'n' does not abort an otherwise
runnable test.
- Unload with "modprobe -r" instead of "rmmod" to also remove
dependencies pulled in by modprobe.
- Drop the redundant geteuid() check in the unload path.
- Raise MAX_LOADED_MODULES from 16 to 32.
- cve-2025-21756: drop privileges to nobody after module loading
and regain root in cleanup(), so the reproducer runs from a
non-root context while the framework can still unload modules.
Changes in v2:
- Add tst_module_is_loaded() helper.
- Only load/unload modules that are not already loaded.
- Skip automatic loading when KCONFIG_SKIP_CHECK=1, keeping the
semantics consistent with skipping the config check.
- Document the KCONFIG_SKIP_CHECK=1 behaviour for keyctl29/keyctl30
and the vsock/vsock_loopback mapping.
Li Wang (Hieco) (4):
lib: add module is loaded check
tst_kconfig: load and unload kernel modules for CONFIG_*=m
tst_kconfig: add module mappings for vsock/vsock_loopback
testcases: drop manual tst_modprobe() now handled by tst_kconfig
include/tst_kconfig.h | 21 +++++
include/tst_module.h | 1 +
lib/tst_kconfig.c | 93 +++++++++++++++++++++
lib/tst_module.c | 39 +++++++++
lib/tst_test.c | 13 ++-
testcases/cve/cve-2025-21756.c | 17 ++++
testcases/cve/cve-2026-46331.c | 7 --
testcases/cve/sctphantom.c | 3 -
testcases/kernel/syscalls/keyctl/keyctl23.c | 6 +-
testcases/kernel/syscalls/keyctl/keyctl29.c | 3 -
testcases/kernel/syscalls/keyctl/keyctl30.c | 3 -
11 files changed, 183 insertions(+), 23 deletions(-)
--
2.56.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 19+ messages in thread
* [LTP] [PATCH v8 1/4] lib: add module is loaded check
2026-11-25 3:05 [LTP] [PATCH v8 0/4] tst_kconfig: automatic module load/unload for CONFIG_*=m Li Wang (Hieco)
@ 2026-11-25 3:05 ` Li Wang (Hieco)
2026-11-25 10:34 ` Cyril Hrubis
2026-11-25 10:43 ` [LTP] " linuxtestproject.agent
2026-11-25 3:05 ` [LTP] [PATCH v8 2/4] tst_kconfig: load and unload kernel modules for CONFIG_*=m Li Wang (Hieco)
` (2 subsequent siblings)
3 siblings, 2 replies; 19+ messages in thread
From: Li Wang (Hieco) @ 2026-11-25 3:05 UTC (permalink / raw)
To: chrubis, wakel; +Cc: ltp
Add a helper that checks whether a kernel module is loaded by
looking it up in /proc/modules. Module names are normalized so that
hyphens match the underscores used by the kernel.
Signed-off-by: Li Wang (Hieco) <li.wang@linux.dev>
---
include/tst_module.h | 1 +
lib/tst_module.c | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+)
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);
#endif /* TST_MODULE_H */
diff --git a/lib/tst_module.c b/lib/tst_module.c
index cbd2415d5..db341ec57 100644
--- a/lib/tst_module.c
+++ b/lib/tst_module.c
@@ -21,6 +21,7 @@
*/
#define _GNU_SOURCE
+#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -174,3 +175,41 @@ void tst_module_reload(const char *mod_name, char *const argv[])
tst_module_unload_(NULL, mod_name);
tst_modprobe(mod_name, argv);
}
+
+bool tst_module_is_loaded(const char *mod_name)
+{
+ char line[4096];
+ size_t mod_len = strlen(mod_name);
+ FILE *file;
+
+ file = fopen("/proc/modules", "r");
+ if (!file)
+ return false;
+
+ while (fgets(line, sizeof(line), file)) {
+ char *p = line;
+ size_t i;
+
+ while (*p && !isspace(*p))
+ p++;
+
+ if ((size_t)(p - line) != mod_len)
+ continue;
+
+ for (i = 0; i < mod_len; i++) {
+ char a = (line[i] == '-') ? '_' : line[i];
+ char b = (mod_name[i] == '-') ? '_' : mod_name[i];
+
+ if (a != b)
+ break;
+ }
+
+ if (i == mod_len) {
+ fclose(file);
+ return true;
+ }
+ }
+
+ fclose(file);
+ return false;
+}
--
2.56.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [LTP] [PATCH v8 2/4] tst_kconfig: load and unload kernel modules for CONFIG_*=m
2026-11-25 3:05 [LTP] [PATCH v8 0/4] tst_kconfig: automatic module load/unload for CONFIG_*=m Li Wang (Hieco)
2026-11-25 3:05 ` [LTP] [PATCH v8 1/4] lib: add module is loaded check Li Wang (Hieco)
@ 2026-11-25 3:05 ` Li Wang (Hieco)
2026-11-25 10:48 ` Cyril Hrubis
2026-11-25 3:05 ` [LTP] [PATCH v8 3/4] tst_kconfig: add module mappings for vsock/vsock_loopback Li Wang (Hieco)
2026-11-25 3:05 ` [LTP] [PATCH v8 4/4] testcases: drop manual tst_modprobe() now handled by tst_kconfig Li Wang (Hieco)
3 siblings, 1 reply; 19+ messages in thread
From: Li Wang (Hieco) @ 2026-11-25 3:05 UTC (permalink / raw)
To: chrubis, wakel; +Cc: ltp
Tests that depend on a config set to =m must currently load the
module themselves, and may fail with misleading errors when it is
not loaded, e.g. bind() returning EADDRNOTAVAIL for AF_VSOCK when
vsock_loopback is missing.
Record the module for every config_module_maps[] entry seen as =m
and not already loaded while parsing the kernel config. When
needs_kconfigs is set, load them via tst_modprobe() after a
successful tst_kconfig_check(), and unload them in reverse order
from do_cleanup(). Only modules that were actually loaded are
unloaded; modules still in use are skipped. Dependencies pulled in
by modprobe are not unloaded.
Modules are only loaded when running as root.
Signed-off-by: Li Wang (Hieco) <li.wang@linux.dev>
---
include/tst_kconfig.h | 21 ++++++++++
lib/tst_kconfig.c | 91 +++++++++++++++++++++++++++++++++++++++++++
lib/tst_test.c | 13 +++++--
3 files changed, 122 insertions(+), 3 deletions(-)
diff --git a/include/tst_kconfig.h b/include/tst_kconfig.h
index c454f3467..d603919d9 100644
--- a/include/tst_kconfig.h
+++ b/include/tst_kconfig.h
@@ -105,4 +105,25 @@ void tst_kcmdline_parse(struct tst_kcmdline_var params[], size_t params_len);
*/
int tst_has_slow_kconfig(void);
+/**
+ * tst_kconfig_module_load() - Load kernel modules for CONFIG_*=m entries.
+ *
+ * Loads the modules for CONFIG_* options found as =m in the kernel config
+ * that are not already loaded, in the order they were found.
+ * Does nothing when not running as root.
+ */
+void tst_kconfig_module_load(void);
+
+/**
+ * tst_kconfig_module_unload() - Unload modules loaded by
+ * tst_kconfig_module_load().
+ *
+ * Unloads, in reverse order, only the modules that were actually loaded.
+ * Modules still in use are skipped silently. Dependencies pulled in by
+ * modprobe are not unloaded.
+ *
+ * Called from do_cleanup(), so it runs regardless of the test result.
+ */
+void tst_kconfig_module_unload(void);
+
#endif /* TST_KCONFIG_H__ */
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
@@ -16,8 +16,16 @@
#include "tst_bool_expr.h"
#include "tst_safe_stdio.h"
+#include "lapi/syscalls.h"
+#include "tst_module.h"
#include "tst_kconfig_checks.h"
+#define MAX_LOADED_MODULES 32
+
+static const char *loaded_modules[MAX_LOADED_MODULES];
+static unsigned int module_count;
+static unsigned int loaded_module_count;
+
static int kconfig_skip_check(void)
{
char *skipped = getenv("KCONFIG_SKIP_CHECK");
@@ -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);
+ }
+
tst_res(TDEBUG, "Running module check for '%s'", var->id);
if (tst_check_module_driver(config_module_maps[i].module_name)) {
@@ -189,6 +203,38 @@ static void kconfig_module_check(struct tst_kconfig_var *var)
}
}
+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 < module_count; i++) {
+ if (!strcmp(loaded_modules[i], mod))
+ return;
+ }
+
+ if (module_count >= MAX_LOADED_MODULES)
+ tst_brk(TBROK, "Too many modules, increase MAX_LOADED_MODULES");
+
+ loaded_modules[module_count++] = mod;
+}
+
static inline int kconfig_parse_line(const char *line,
struct tst_kconfig_var *vars,
unsigned int vars_len)
@@ -268,6 +314,7 @@ out:
vars[i].choice = 'm';
kconfig_runtime_check(&vars[i]);
kconfig_module_check(&vars[i]);
+ kconfig_module_record(&vars[i]);
return 1;
}
}
@@ -300,6 +347,50 @@ exit:
close_kconfig(fp);
}
+void tst_kconfig_module_load(void)
+{
+ unsigned int i;
+
+ if (geteuid() != 0)
+ return;
+
+ for (i = 0; i < module_count; i++) {
+ tst_res(TDEBUG, "Loading module '%s'", loaded_modules[i]);
+ tst_modprobe(loaded_modules[i], NULL);
+
+ loaded_module_count++;
+ }
+}
+
+void tst_kconfig_module_unload(void)
+{
+ const char *name;
+
+ if (!loaded_module_count)
+ return;
+
+ while (loaded_module_count > 0) {
+ name = loaded_modules[--loaded_module_count];
+
+ tst_res(TDEBUG, "Unloading module '%s'", name);
+
+ if (!syscall(__NR_delete_module, name, O_NONBLOCK))
+ continue;
+
+ switch (errno) {
+ case ENOENT: /* already unloaded */
+ case EWOULDBLOCK: /* in use */
+ case EBUSY: /* still loading or unloading */
+ case ENOSYS: /* no CONFIG_MODULE_UNLOAD */
+ break;
+ default:
+ tst_res(TWARN | TERRNO, "Failed to unload module '%s'", name);
+ }
+ }
+
+ loaded_module_count = 0;
+}
+
static size_t array_len(const char *const kconfigs[])
{
size_t i = 0;
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 10ff73397..a9e679bee 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -1471,12 +1471,16 @@ static void do_setup(int argc, char *argv[])
check_supported_kver();
- if (tst_test->needs_kconfigs && tst_kconfig_check(tst_test->needs_kconfigs))
- tst_brk(TCONF, "Aborting due to unsuitable kernel config, see above!");
-
if (tst_test->needs_root && geteuid() != 0)
tst_brk(TCONF, "Test needs to be run as root");
+ if (tst_test->needs_kconfigs) {
+ if (tst_kconfig_check(tst_test->needs_kconfigs))
+ tst_brk(TCONF, "Aborting due to unsuitable kernel config, see above!");
+
+ tst_kconfig_module_load();
+ }
+
if (tst_test->min_kver)
check_kver(tst_test->min_kver, 1);
@@ -1690,6 +1694,9 @@ static void do_cleanup(void)
if (tst_test->restore_wallclock)
tst_wallclock_restore();
+ if (tst_test->needs_kconfigs)
+ tst_kconfig_module_unload();
+
cleanup_ipc();
}
--
2.56.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [LTP] [PATCH v8 3/4] tst_kconfig: add module mappings for vsock/vsock_loopback
2026-11-25 3:05 [LTP] [PATCH v8 0/4] tst_kconfig: automatic module load/unload for CONFIG_*=m Li Wang (Hieco)
2026-11-25 3:05 ` [LTP] [PATCH v8 1/4] lib: add module is loaded check Li Wang (Hieco)
2026-11-25 3:05 ` [LTP] [PATCH v8 2/4] tst_kconfig: load and unload kernel modules for CONFIG_*=m Li Wang (Hieco)
@ 2026-11-25 3:05 ` Li Wang (Hieco)
2026-11-25 10:53 ` Cyril Hrubis
2026-11-25 3:05 ` [LTP] [PATCH v8 4/4] testcases: drop manual tst_modprobe() now handled by tst_kconfig Li Wang (Hieco)
3 siblings, 1 reply; 19+ messages in thread
From: Li Wang (Hieco) @ 2026-11-25 3:05 UTC (permalink / raw)
To: chrubis, wakel; +Cc: ltp
Map CONFIG_VSOCKETS to "vsock" and CONFIG_VSOCKETS_LOOPBACK to
"vsock_loopback" so tst_kconfig can load them on demand.
cve-2025-21756 binds to VMADDR_CID_LOCAL and therefore needs
vsock_loopback. Without the module loaded, bind() fails with
EADDRNOTAVAIL and the test aborts with TBROK. Declare both configs in
needs_kconfigs so the modules are loaded first.
The test needs root only to load the modules; the reproducer runs as
an ordinary non-root process in the initial namespace, where it can
use loopback VSOCK on non-privileged ports. Drop privileges to nobody
in setup() after the modules are loaded; the framework unloads the
modules from its still-root context, so no restore is needed in
cleanup().
Signed-off-by: Li Wang (Hieco) <li.wang@linux.dev>
---
lib/tst_kconfig.c | 2 ++
testcases/cve/cve-2025-21756.c | 17 +++++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/lib/tst_kconfig.c b/lib/tst_kconfig.c
index 8b4d0e2ef..2ccd86fb7 100644
--- a/lib/tst_kconfig.c
+++ b/lib/tst_kconfig.c
@@ -175,6 +175,8 @@ static struct config_module_map {
{"CONFIG_NET_ACT_PEDIT", "act_pedit"},
{"CONFIG_PKCS8_PRIVATE_KEY_PARSER", "pkcs8_key_parser"},
{"CONFIG_X509_CERTIFICATE_PARSER", "x509_key_parser"},
+ {"CONFIG_VSOCKETS", "vsock"},
+ {"CONFIG_VSOCKETS_LOOPBACK", "vsock_loopback"},
{}
};
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
@@ -13,12 +13,22 @@
* Beware, this test will crash the system.
*/
+#include <pwd.h>
+
#include "tst_test.h"
#include "lapi/vm_sockets.h"
#define MAX_PORT_RETRIES 24
#define VMADDR_CID_NONEXISTING 42
+static void setup(void)
+{
+ struct passwd *pw = SAFE_GETPWNAM("nobody");
+
+ SAFE_SETEGID(pw->pw_gid);
+ SAFE_SETEUID(pw->pw_uid);
+}
+
static int vsock_bind(unsigned int cid, unsigned int port, int type)
{
int sock;
@@ -85,8 +95,15 @@ static void run(void)
}
static struct tst_test test = {
+ .needs_root = 1,
+ .setup = setup,
.test_all = run,
.taint_check = TST_TAINT_W | TST_TAINT_D,
+ .needs_kconfigs = (const char *const[]) {
+ "CONFIG_VSOCKETS",
+ "CONFIG_VSOCKETS_LOOPBACK",
+ NULL
+ },
.tags = (const struct tst_tag[]) {
{"linux-git", "fcdd2242c0231032fc84e1404315c245ae56322a"},
{"CVE", "2025-21756"},
--
2.56.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [LTP] [PATCH v8 4/4] testcases: drop manual tst_modprobe() now handled by tst_kconfig
2026-11-25 3:05 [LTP] [PATCH v8 0/4] tst_kconfig: automatic module load/unload for CONFIG_*=m Li Wang (Hieco)
` (2 preceding siblings ...)
2026-11-25 3:05 ` [LTP] [PATCH v8 3/4] tst_kconfig: add module mappings for vsock/vsock_loopback Li Wang (Hieco)
@ 2026-11-25 3:05 ` Li Wang (Hieco)
2026-11-25 11:00 ` Cyril Hrubis
3 siblings, 1 reply; 19+ messages in thread
From: Li Wang (Hieco) @ 2026-11-25 3:05 UTC (permalink / raw)
To: chrubis, wakel; +Cc: ltp
Now that tst_kconfig loads the modules for every CONFIG_*=m entry
listed in config_module_maps[] and unloads them again at cleanup
time, tests no longer have to call tst_modprobe() from setup().
Drop the explicit tst_modprobe() calls, and the now unused
tst_module.h includes, from:
- cve-2026-46331.c: sch_ingress, cls_matchall, act_pedit
- sctphantom.c: sctp
- keyctl23.c: x509_key_parser
- keyctl29.c: x509_key_parser
- keyctl30.c: pkcs8_key_parser
All tests already declare the matching configs in .needs_kconfigs,
so tst_kconfig takes care of loading the modules before setup()
runs and unloading them once the test finishes.
BTW, with KCONFIG_SKIP_CHECK=1 the config check returns early,
so the automatic module loading is skipped as well. Users who set
that variable are expected to ensure the required modules are
loaded themselves.
Signed-off-by: Li Wang (Hieco) <li.wang@linux.dev>
---
testcases/cve/cve-2026-46331.c | 7 -------
testcases/cve/sctphantom.c | 3 ---
testcases/kernel/syscalls/keyctl/keyctl23.c | 6 ++----
testcases/kernel/syscalls/keyctl/keyctl29.c | 3 ---
testcases/kernel/syscalls/keyctl/keyctl30.c | 3 ---
5 files changed, 2 insertions(+), 20 deletions(-)
diff --git a/testcases/cve/cve-2026-46331.c b/testcases/cve/cve-2026-46331.c
index 439b1280a..e5a81c833 100644
--- a/testcases/cve/cve-2026-46331.c
+++ b/testcases/cve/cve-2026-46331.c
@@ -44,7 +44,6 @@
#include <linux/rtnetlink.h>
#include "tst_test.h"
-#include "tst_module.h"
#include "tst_net.h"
#include "tst_netdevice.h"
#include "lapi/if_ether.h"
@@ -136,12 +135,6 @@ static void setup(void)
{
struct sockaddr_in addr;
struct passwd *pw;
- static const char *const mods[] = {
- "sch_ingress", "cls_matchall", "act_pedit"
- };
-
- for (unsigned int i = 0; i < ARRAY_SIZE(mods); i++)
- tst_modprobe(mods[i], NULL);
/* Drop privileges so the reproducer runs as an unprivileged user */
pw = SAFE_GETPWNAM("nobody");
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
@@ -50,7 +50,6 @@
*/
#include "tst_test.h"
-#include "tst_module.h"
#include "tst_checksum.h"
#include "tst_safe_net.h"
@@ -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);
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");
user_key = SAFE_NEW_USER_KEY("k", PAYLOAD, sizeof(PAYLOAD),
diff --git a/testcases/kernel/syscalls/keyctl/keyctl29.c b/testcases/kernel/syscalls/keyctl/keyctl29.c
index afc0a093c..e66b39bcb 100644
--- a/testcases/kernel/syscalls/keyctl/keyctl29.c
+++ b/testcases/kernel/syscalls/keyctl/keyctl29.c
@@ -23,7 +23,6 @@
#include "keyctl_common.h"
#include "keyctl_pkey_data.h"
-#include "tst_module.h"
static key_serial_t cert_key;
static struct keyctl_pkey_query *query_buf;
@@ -32,8 +31,6 @@ static void setup(void)
{
SAFE_KEYCTL(KEYCTL_JOIN_SESSION_KEYRING, 0, 0, 0, 0);
- tst_modprobe("x509_key_parser", NULL);
-
cert_key = add_asymmetric_key_or_tconf("cert", rsa2048_cert,
sizeof(rsa2048_cert),
"CONFIG_X509_CERTIFICATE_PARSER");
diff --git a/testcases/kernel/syscalls/keyctl/keyctl30.c b/testcases/kernel/syscalls/keyctl/keyctl30.c
index ef51bba33..4f43007e0 100644
--- a/testcases/kernel/syscalls/keyctl/keyctl30.c
+++ b/testcases/kernel/syscalls/keyctl/keyctl30.c
@@ -20,7 +20,6 @@
#include "keyctl_common.h"
#include "keyctl_pkey_data.h"
-#include "tst_module.h"
static key_serial_t priv_key;
static struct keyctl_pkey_query *query_buf;
@@ -29,8 +28,6 @@ static void setup(void)
{
SAFE_KEYCTL(KEYCTL_JOIN_SESSION_KEYRING, 0, 0, 0, 0);
- tst_modprobe("pkcs8_key_parser", NULL);
-
priv_key = add_asymmetric_key_or_tconf("priv", rsa2048_pkcs8,
sizeof(rsa2048_pkcs8),
"CONFIG_PKCS8_PRIVATE_KEY_PARSER");
--
2.56.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [LTP] [PATCH v8 1/4] lib: add module is loaded check
2026-11-25 3:05 ` [LTP] [PATCH v8 1/4] lib: add module is loaded check Li Wang (Hieco)
@ 2026-11-25 10:34 ` Cyril Hrubis
2026-11-25 10:43 ` [LTP] " linuxtestproject.agent
1 sibling, 0 replies; 19+ messages in thread
From: Cyril Hrubis @ 2026-11-25 10:34 UTC (permalink / raw)
To: Li Wang (Hieco); +Cc: wakel, ltp
Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [LTP] lib: add module is loaded check
2026-11-25 3:05 ` [LTP] [PATCH v8 1/4] lib: add module is loaded check Li Wang (Hieco)
2026-11-25 10:34 ` Cyril Hrubis
@ 2026-11-25 10:43 ` linuxtestproject.agent
1 sibling, 0 replies; 19+ messages in thread
From: linuxtestproject.agent @ 2026-11-25 10:43 UTC (permalink / raw)
To: Li Wang; +Cc: ltp
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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [LTP] [PATCH v8 2/4] tst_kconfig: load and unload kernel modules for CONFIG_*=m
2026-11-25 3:05 ` [LTP] [PATCH v8 2/4] tst_kconfig: load and unload kernel modules for CONFIG_*=m Li Wang (Hieco)
@ 2026-11-25 10:48 ` Cyril Hrubis
2026-11-26 3:12 ` Li Wang
0 siblings, 1 reply; 19+ messages in thread
From: Cyril Hrubis @ 2026-11-25 10:48 UTC (permalink / raw)
To: Li Wang (Hieco); +Cc: wakel, ltp
Hi!
> +void tst_kconfig_module_unload(void)
> +{
> + const char *name;
> +
> + if (!loaded_module_count)
> + return;
This if is not really needed here.
> + while (loaded_module_count > 0) {
> + name = loaded_modules[--loaded_module_count];
> +
> + tst_res(TDEBUG, "Unloading module '%s'", name);
> +
> + if (!syscall(__NR_delete_module, name, O_NONBLOCK))
> + continue;
> +
> + switch (errno) {
> + case ENOENT: /* already unloaded */
> + case EWOULDBLOCK: /* in use */
> + case EBUSY: /* still loading or unloading */
> + case ENOSYS: /* no CONFIG_MODULE_UNLOAD */
> + break;
> + default:
> + tst_res(TWARN | TERRNO, "Failed to unload module '%s'", name);
> + }
> + }
> +
> + loaded_module_count = 0;
> +}
> +
> static size_t array_len(const char *const kconfigs[])
> {
> size_t i = 0;
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [LTP] [PATCH v8 3/4] tst_kconfig: add module mappings for vsock/vsock_loopback
2026-11-25 3:05 ` [LTP] [PATCH v8 3/4] tst_kconfig: add module mappings for vsock/vsock_loopback Li Wang (Hieco)
@ 2026-11-25 10:53 ` Cyril Hrubis
2026-11-26 3:58 ` Li Wang
0 siblings, 1 reply; 19+ messages in thread
From: Cyril Hrubis @ 2026-11-25 10:53 UTC (permalink / raw)
To: Li Wang (Hieco); +Cc: wakel, ltp
Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
> The test needs root only to load the modules; the reproducer runs as
> an ordinary non-root process in the initial namespace, where it can
> use loopback VSOCK on non-privileged ports. Drop privileges to nobody
> in setup() after the modules are loaded; the framework unloads the
> modules from its still-root context, so no restore is needed in
> cleanup().
One idea I have in my mind is to add ".run_as_nobody" into the tst_test
structure, which would:
- run the setup() and cleanup() as root
- switched to nobody for run()
I guess that first of all we should check how common is that pattern and
add the support if needed...
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [LTP] [PATCH v8 4/4] testcases: drop manual tst_modprobe() now handled by tst_kconfig
2026-11-25 3:05 ` [LTP] [PATCH v8 4/4] testcases: drop manual tst_modprobe() now handled by tst_kconfig Li Wang (Hieco)
@ 2026-11-25 11:00 ` Cyril Hrubis
0 siblings, 0 replies; 19+ messages in thread
From: Cyril Hrubis @ 2026-11-25 11:00 UTC (permalink / raw)
To: Li Wang (Hieco); +Cc: wakel, ltp
Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [LTP] [PATCH v8 2/4] tst_kconfig: load and unload kernel modules for CONFIG_*=m
2026-11-25 10:48 ` Cyril Hrubis
@ 2026-11-26 3:12 ` Li Wang
0 siblings, 0 replies; 19+ messages in thread
From: Li Wang @ 2026-11-26 3:12 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: wakel, ltp
> Hi!
> > +void tst_kconfig_module_unload(void)
> > +{
> > + const char *name;
> > +
> > + if (!loaded_module_count)
> > + return;
>
> This if is not really needed here.
Good point, patchset merged with your suggetion, thanks!
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [LTP] [PATCH v8 3/4] tst_kconfig: add module mappings for vsock/vsock_loopback
2026-11-25 10:53 ` Cyril Hrubis
@ 2026-11-26 3:58 ` Li Wang
0 siblings, 0 replies; 19+ messages in thread
From: Li Wang @ 2026-11-26 3:58 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: wakel, ltp
> One idea I have in my mind is to add ".run_as_nobody" into the tst_test
> structure, which would:
>
> - run the setup() and cleanup() as root
> - switched to nobody for run()
>
> I guess that first of all we should check how common is that pattern and
> add the support if needed...
Right, I'll look into it when I'm free and see if it's worth doing.
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2026-11-26 3:58 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 3:05 [LTP] [PATCH v8 0/4] tst_kconfig: automatic module load/unload for CONFIG_*=m Li Wang (Hieco)
2026-11-25 3:05 ` [LTP] [PATCH v8 1/4] lib: add module is loaded check Li Wang (Hieco)
2026-11-25 10:34 ` Cyril Hrubis
2026-11-25 10:43 ` [LTP] " linuxtestproject.agent
2026-11-25 3:05 ` [LTP] [PATCH v8 2/4] tst_kconfig: load and unload kernel modules for CONFIG_*=m Li Wang (Hieco)
2026-11-25 10:48 ` Cyril Hrubis
2026-11-26 3:12 ` Li Wang
2026-11-25 3:05 ` [LTP] [PATCH v8 3/4] tst_kconfig: add module mappings for vsock/vsock_loopback Li Wang (Hieco)
2026-11-25 10:53 ` Cyril Hrubis
2026-11-26 3:58 ` Li Wang
2026-11-25 3:05 ` [LTP] [PATCH v8 4/4] testcases: drop manual tst_modprobe() now handled by tst_kconfig Li Wang (Hieco)
2026-11-25 11:00 ` Cyril Hrubis
-- 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-11-02 2:43 [LTP] [PATCH v6 1/4] " Li Wang (Hieco)
2026-11-02 8:26 ` [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
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.