From: Petr Pavlu <petr.pavlu@suse.com>
To: Jinchao Wang <wangjinchao600@gmail.com>
Cc: Luis Chamberlain <mcgrof@kernel.org>,
Daniel Gomez <da.gomez@kernel.org>,
Sami Tolvanen <samitolvanen@google.com>,
linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 3/4] module: centralize no-versions force load check
Date: Mon, 1 Sep 2025 11:30:11 +0200 [thread overview]
Message-ID: <5ac979fd-7a84-4633-a53a-55be955faed4@suse.com> (raw)
In-Reply-To: <20250829084927.156676-4-wangjinchao600@gmail.com>
On 8/29/25 10:49 AM, Jinchao Wang wrote:
> Move try_to_force_load() call from check_version() to
> check_modstruct_version() to handle "no versions" case only once before
> other version checks.
>
> Suggested-by: Petr Pavlu <petr.pavlu@suse.com>
> Signed-off-by: Jinchao Wang <wangjinchao600@gmail.com>
> ---
> kernel/module/version.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/module/version.c b/kernel/module/version.c
> index 2beefeba82d9..7a458c681049 100644
> --- a/kernel/module/version.c
> +++ b/kernel/module/version.c
> @@ -41,9 +41,9 @@ int check_version(const struct load_info *info,
> return 1;
> }
>
> - /* No versions at all? modprobe --force does this. */
> + /* No versions? Ok, already tainted in check_modstruct_version(). */
> if (versindex == 0)
> - return try_to_force_load(mod, symname) == 0;
> + return 1;
>
> versions = (void *)sechdrs[versindex].sh_addr;
> num_versions = sechdrs[versindex].sh_size
> @@ -80,6 +80,7 @@ int check_modstruct_version(const struct load_info *info,
> .gplok = true,
> };
> bool have_symbol;
> + char *reason;
>
> /*
> * Since this should be found in kernel (which can't be removed), no
> @@ -90,6 +91,11 @@ int check_modstruct_version(const struct load_info *info,
> have_symbol = find_symbol(&fsa);
> BUG_ON(!have_symbol);
>
> + /* No versions at all? modprobe --force does this. */
> + if (!info->index.vers && !info->index.vers_ext_crc) {
> + reason = "no versions for imported symbols";
> + return try_to_force_load(mod, reason) == 0;
> + }
> return check_version(info, "module_layout", mod, fsa.crc);
> }
>
Nit: I would prefer this to be formatted as:
+ /* No versions at all? modprobe --force does this. */
+ if (!info->index.vers && !info->index.vers_ext_crc)
+ return try_to_force_load(
+ mod, "no versions for imported symbols") == 0;
+
Nonetheless, it looks ok to me functionality-wise.
Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
--
Thanks,
Petr
next prev parent reply other threads:[~2025-09-01 9:30 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-29 8:49 [PATCH v3 0/4] module: logging and code improvements Jinchao Wang
2025-08-29 8:49 ` [PATCH v3 1/4] module: signing: Use pr_err for signature rejection Jinchao Wang
2025-09-01 9:25 ` Petr Pavlu
2025-09-01 18:18 ` Daniel Gomez
2025-09-02 1:57 ` Jinchao Wang
2025-08-29 8:49 ` [PATCH v3 2/4] module: show why force load fails Jinchao Wang
2025-09-01 9:26 ` Petr Pavlu
2025-09-01 18:29 ` Daniel Gomez
2025-09-02 2:06 ` Jinchao Wang
2025-08-29 8:49 ` [PATCH v3 3/4] module: centralize no-versions force load check Jinchao Wang
2025-09-01 9:30 ` Petr Pavlu [this message]
2025-08-29 8:49 ` [PATCH v3 4/4] module: separate vermagic and livepatch checks Jinchao Wang
2025-09-01 9:34 ` Petr Pavlu
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=5ac979fd-7a84-4633-a53a-55be955faed4@suse.com \
--to=petr.pavlu@suse.com \
--cc=da.gomez@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=samitolvanen@google.com \
--cc=wangjinchao600@gmail.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®