Linux Test Project
 help / color / mirror / Atom feed
From: Li Wang <li.wang@linux.dev>
To: linuxtestproject.agent@gmail.com
Cc: ltp@lists.linux.it
Subject: Re: [LTP] tst_kconfig: load and unload kernel modules for CONFIG_*=m
Date: Thu, 8 Oct 2026 13:09:58 +0800	[thread overview]
Message-ID: <asclptsE0nKmz2eq@linux.dev> (raw)
In-Reply-To: <20261007141758.9828-1-linuxtestproject.agent@gmail.com>

On Wed, Oct 07, 2026 at 02:17:58PM +0000, linuxtestproject.agent@gmail.com wrote:
> Hi Li,
> 
> On Wed, 7 Oct 2026, Li Wang wrote:
> > tst_kconfig: load and unload kernel modules for CONFIG_*=m
> 
> --- [PATCH 1/3] ---
> 
> > diff --git a/lib/tst_kconfig.c b/lib/tst_kconfig.c
> > +	if (loaded_module_count < MAX_LOADED_MODULES)
> > +		loaded_modules[loaded_module_count++] = mod;
> 
> High: This records config matches, not modules newly loaded by the test,
> so cleanup can remove an unused module that was already loaded beforehand.
> A read-only tst_kconfig_read() during a callback also adds unload targets
> without loading them. Separate config discovery from ownership tracking
> and unload only modules successfully added by this test.

Good point, will fix it in v2.

> 
> > diff --git a/lib/tst_test.c b/lib/tst_test.c
> > +	tst_kconfig_module_unload_all();
> 
> High: Loading happens once in the library parent, but this cleanup runs
> in each test child. Setup aborts and killed children leak modules, later
> variants can lose modules removed by the first child, and cve-2026-46331
> cannot unload after dropping initial-user-namespace privileges. Move
> unloading to parent do_cleanup(), after all variants and resource teardown.

Agreed.

> 
> > diff --git a/lib/tst_kconfig.c b/lib/tst_kconfig.c
> > +		tst_modprobe(loaded_modules[i], NULL);
> > +		const char *const argv[] = { "rmmod", loaded_modules[i - 1], NULL };
> 
> Medium: modprobe also inserts dependencies that this list never records;
> with both initially absent, loading can-raw inserts can, but cleanup only
> removes can-raw and leaves can loaded. Track newly inserted dependencies
> relative to the initial module state and remove owned modules in
> dependency order.
> 
> > diff --git a/include/tst_kconfig.h b/include/tst_kconfig.h
> > +/*
> > + * tst_kconfig_module_load() - Load kernel modules for CONFIG_*=m entries.
> 
> Low: Both new public API comments use /* rather than /** and are omitted
> from the generated kernel-doc reference. Use kernel-doc comment openers
> for both declarations.

+1

> 
> --- [PATCH 2/3] ---
> 
> > Map CONFIG_VSOCKETS and CONFIG_VSOCKETS_LOOPBACK to their kernel
> > modules (vsock, vsock_loopback).
> 
> Low: The body only restates the mappings and does not explain the new
> config and privilege gates in cve-2025-21756. Explain the missing-loopback
> bind failure and why the test now requires root.

Will add the note in v2.

> 
> > diff --git a/testcases/cve/cve-2025-21756.c b/testcases/cve/cve-2025-21756.c
> > +	.needs_root = 1,
> 
> Low: Document this new root requirement in the test's high-level
> description, identifying module loading as the privileged operation.

Sure.

> 
> --- [PATCH 3/3] ---
> 
> > diff --git a/testcases/kernel/syscalls/keyctl/keyctl29.c b/testcases/kernel/syscalls/keyctl/keyctl29.c
> > -	tst_modprobe("x509_key_parser", NULL);
> > diff --git a/testcases/kernel/syscalls/keyctl/keyctl30.c b/testcases/kernel/syscalls/keyctl/keyctl30.c
> > -	tst_modprobe("pkcs8_key_parser", NULL);
> 
> Medium: With KCONFIG_SKIP_CHECK=1, tst_kconfig_check() returns before
> recording modules, leaving these removed loads without a replacement.
> When parser modules are installed but unloaded, keyctl29/keyctl30 now
> skip with EBADMSG instead of executing their checks. Preserve module
> setup independently of config validation, or retain the explicit loads.

With KCONFIG_SKIP_CHECK=1 the config check returns early and the
automatic module loading is skipped as well. However, I consider
that the intended behaviour rather than a regression.

KCONFIG_SKIP_CHECK=1 is an explicit opt-out from the kernel config
check. Loading the modules depends on the result of that check: the
list of modules is built by kconfig_parse_line() while parsing the
config, and with the check skipped that parsing never happens. To
load the modules anyway we would have to either re-parse the config,
which contradicts the whole point of skipping it, or hardcode the
module list, which would duplicate config_module_maps[].

So skipping the automatic load together with the config check keeps
the semantics consistent: KCONFIG_SKIP_CHECK=1 skips everything that
depends on the config check, and users who set it are expected to
make sure the modules their tests need are already loaded.

The affected tests are still executed normally when the config check
runs, which is the default. I've added a note to the commit message
to make the KCONFIG_SKIP_CHECK=1 behaviour explicit.


-- 
Regards,
Li Wang

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

  reply	other threads:[~2026-10-08  5:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-07 10:57 [LTP] [PATCH 0/3] tst_kconfig: automatic module load/unload for CONFIG_*=m Li Wang
2026-10-07 10:57 ` [LTP] [PATCH 1/3] tst_kconfig: load and unload kernel modules " Li Wang
2026-10-07 14:17   ` [LTP] " linuxtestproject.agent
2026-10-08  5:09     ` Li Wang [this message]
2026-10-07 10:57 ` [LTP] [PATCH 2/3] tst_kconfig: add module mappings for vsock/vsock_loopback Li Wang
2026-10-07 10:57 ` [LTP] [PATCH 3/3] testcases: drop manual tst_modprobe() now handled by tst_kconfig 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=asclptsE0nKmz2eq@linux.dev \
    --to=li.wang@linux.dev \
    --cc=linuxtestproject.agent@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox