mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bradley Morgan <bradley.morgan@linux.dev>
To: 958028483@qq.com
Cc: atomlin@atomlin.com, da.gomez@kernel.org, huangchao@kylinos.cn,
	linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org,
	mcgrof@kernel.org, petr.pavlu@suse.com, samitolvanen@google.com
Subject: Re: [PATCH] module: report why forced module loading is rejected
Date: Sat, 28 Nov 2026 13:14:54 +0000	[thread overview]
Message-ID: <5F50ADBD-0DC8-4A40-9EA2-DD39FA51F7E8@linux.dev> (raw)
In-Reply-To: <tencent_192A8A137B6CC69DDBF028C27205824BAC09@qq.com>

On 27 November 2026 03:43:17 GMT, Chao Huang <958028483@qq.com> wrote:
>From: Chao Huang <huangchao@kylinos.cn>
>
>When CONFIG_MODULE_FORCE_LOAD is disabled, try_to_force_load() returns
>-ENOEXEC without logging why the module was rejected. For example, with
>CONFIG_MODVERSIONS enabled, finit_module() with
>MODULE_INIT_IGNORE_MODVERSIONS suppresses the version sections and causes
>the module_layout version check to take this path. Users only see
>"Invalid module format" from insmod, without a diagnostic in the kernel
>log explaining the failure.
>
>Log the module name and the supplied reason, and state that
>CONFIG_MODULE_FORCE_LOAD is not enabled before returning -ENOEXEC. This
>also diagnoses the missing vermagic and exported-symbol version paths
>that use the same helper.
>
>Fixes: 826e4506a0ac ("Make forced module loading optional")

This is correct.

Reviewed-by: Bradley Morgan <bradley.morgan@linux.dev>


>Signed-off-by: Chao Huang <huangchao@kylinos.cn>
>---
>Testing: rebuilt the x86_64 bzImage and modules with CONFIG_MODVERSIONS=y
>and CONFIG_MODULE_FORCE_LOAD disabled, and booted the patched kernel with:
>
>  vng --run out/arch/x86/boot/bzImage --cpus 2 --memory 2G \
>      --disable-microvm --verbose
>
>A matching test module loaded and unloaded successfully without flags.
>finit_module() with MODULE_INIT_IGNORE_MODVERSIONS,
>MODULE_INIT_IGNORE_VERMAGIC, or both flags failed with ENOEXEC and logged
>the corresponding reason and disabled configuration option. 
>
> kernel/module/main.c | 2 ++
> 1 file changed, 2 insertions(+)
>
>diff --git a/kernel/module/main.c b/kernel/module/main.c
>index 34e0204ea37c..010b5d69e50c 100644
>--- a/kernel/module/main.c
>+++ b/kernel/module/main.c
>@@ -1124,6 +1124,8 @@ int try_to_force_load(struct module *mod, const char *reason)
> 	add_taint_module(mod, TAINT_FORCED_MODULE, LOCKDEP_NOW_UNRELIABLE);
> 	return 0;
> #else

Suggestion:


/* CONFIG_MODULE_FORCE_LOAD is not
 * enabled, let's just tell the user
 * that it won't forcefully load
 */

I'm aware that's very long, you can shorten down or decline suggestion.

>+	pr_err("%s: %s: CONFIG_MODULE_FORCE_LOAD is not enabled\n",
>+	       mod->name, reason);
> 	return -ENOEXEC;
> #endif
> }
>
>base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
>

--- Thanks!

      reply	other threads:[~2026-11-28 13:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27  3:43 Chao Huang
2026-11-28 13:14 ` Bradley Morgan [this message]

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=5F50ADBD-0DC8-4A40-9EA2-DD39FA51F7E8@linux.dev \
    --to=bradley.morgan@linux.dev \
    --cc=958028483@qq.com \
    --cc=atomlin@atomlin.com \
    --cc=da.gomez@kernel.org \
    --cc=huangchao@kylinos.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=petr.pavlu@suse.com \
    --cc=samitolvanen@google.com \
    /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

all inboxes | Powered by JetHome®