Skip to content

tst_kconfig: automatic module load/unload for CONFIG_*=m

Li Wang (Hieco) ltp 7 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v7 Latest4 patches 7 repliesIn review
  2. v64 patches 1 replySuperseded
  3. v54 patches 1 replySuperseded
Earlier versions · 4
VersionPostedPatchesRepliesStatus
v44 patches3 repliesSuperseded
v34 patches9 repliesSuperseded
v24 patches2 repliesSuperseded
v13 patches2 repliesSuperseded

Changes in v7 from the cover letter

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

Patches in v7 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4lib: add module is loaded checkinclude/tst_module.h lib/tst_module.c+40 -04 replies
2/4tst_kconfig: load and unload kernel modules for CONFIG_*=minclude/tst_kconfig.h lib/tst_kconfig.c lib/tst_test.c+120 -33 replies
3/4tst_kconfig: add module mappings for vsock/vsock_loopbacklib/tst_kconfig.c testcases/cve/cve-2025-21756.c+19 -00 replies
4/4testcases: drop manual tst_modprobe() now handled by tst_kconfigtestcases/cve/cve-2026-46331.c testcases/cve/sctphantom.c testcases/kernel/syscalls/keyctl/keyctl23.c +2 more+2 -200 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v7 yet.

Read the v7 thread

Cover letter [LTP] [PATCH v7 0/4] tst_kconfig: automatic module load/unload for CONFIG_*=m

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 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                           | 91 +++++++++++++++++++++
 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, 181 insertions(+), 23 deletions(-)
Signature · 5 lines
2.56.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp