From: Daniel Gomez <da.gomez@kernel.org>
To: Petr Pavlu <petr.pavlu@suse.com>,
Luis Chamberlain <mcgrof@kernel.org>,
Sami Tolvanen <samitolvanen@google.com>,
Daniel Gomez <da.gomez@samsung.com>
Cc: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 5/5] module: Rename MAX_PARAM_PREFIX_LEN to __MODULE_NAME_LEN
Date: Mon, 28 Jul 2025 08:48:29 +0200 [thread overview]
Message-ID: <93b81672-0604-42d1-8a10-0fc88ba2efd6@kernel.org> (raw)
In-Reply-To: <20250630143535.267745-6-petr.pavlu@suse.com>
On 30/06/2025 16.32, Petr Pavlu wrote:
> The maximum module name length (MODULE_NAME_LEN) is somewhat confusingly
> defined in terms of the maximum parameter prefix length
> (MAX_PARAM_PREFIX_LEN), when in fact the dependency is in the opposite
> direction.
>
> This split originates from commit 730b69d22525 ("module: check kernel param
> length at compile time, not runtime"). The code needed to use
> MODULE_NAME_LEN in moduleparam.h, but because module.h requires
> moduleparam.h, this created a circular dependency. It was resolved by
> introducing MAX_PARAM_PREFIX_LEN in moduleparam.h and defining
> MODULE_NAME_LEN in module.h in terms of MAX_PARAM_PREFIX_LEN.
>
> Rename MAX_PARAM_PREFIX_LEN to __MODULE_NAME_LEN for clarity. This matches
> the similar approach of defining MODULE_INFO in module.h and __MODULE_INFO
> in moduleparam.h.
>
> Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
> ---
> include/linux/module.h | 2 +-
> include/linux/moduleparam.h | 12 ++++++++----
> 2 files changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/include/linux/module.h b/include/linux/module.h
> index 5faa1fb1f4b4..0f1dde3996d9 100644
> --- a/include/linux/module.h
> +++ b/include/linux/module.h
> @@ -32,7 +32,7 @@
> #include <linux/percpu.h>
> #include <asm/module.h>
>
> -#define MODULE_NAME_LEN MAX_PARAM_PREFIX_LEN
> +#define MODULE_NAME_LEN __MODULE_NAME_LEN
>
> struct modversion_info {
> unsigned long crc;
> diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
> index 110e9d09de24..a04a2bc4f51e 100644
> --- a/include/linux/moduleparam.h
> +++ b/include/linux/moduleparam.h
> @@ -6,6 +6,13 @@
> #include <linux/stringify.h>
> #include <linux/kernel.h>
>
> +/*
> + * The maximum module name length, including the NUL byte.
> + * Chosen so that structs with an unsigned long line up, specifically
> + * modversion_info.
> + */
> +#define __MODULE_NAME_LEN (64 - sizeof(unsigned long))
> +
> /* You can override this manually, but generally this should match the
> module name. */
> #ifdef MODULE
> @@ -17,9 +24,6 @@
> #define __MODULE_INFO_PREFIX KBUILD_MODNAME "."
> #endif
>
> -/* Chosen so that structs with an unsigned long line up. */
> -#define MAX_PARAM_PREFIX_LEN (64 - sizeof(unsigned long))
> -
> #define __MODULE_INFO(tag, name, info) \
> static const char __UNIQUE_ID(name)[] \
> __used __section(".modinfo") __aligned(1) \
> @@ -284,7 +288,7 @@ struct kparam_array
>
> /* This is the fundamental function for registering boot/module parameters. */
> #define __module_param_call(prefix, name, ops, arg, perm, level, flags) \
> - static_assert(sizeof(""prefix) - 1 <= MAX_PARAM_PREFIX_LEN); \
> + static_assert(sizeof(""prefix) - 1 <= __MODULE_NAME_LEN); \
> static const char __param_str_##name[] = prefix #name; \
> static struct kernel_param __moduleparam_const __param_##name \
> __used __section("__param") \
LGTM,
Reviewed-by: Daniel Gomez <da.gomez@samsung.com>
next prev parent reply other threads:[~2025-07-28 6:48 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-30 14:32 [PATCH 0/5] module: Fix minor problems related to MODULE_NAME_LEN Petr Pavlu
2025-06-30 14:32 ` [PATCH 1/5] module: Prevent silent truncation of module name in delete_module(2) Petr Pavlu
2025-07-16 19:47 ` Daniel Gomez
2025-06-30 14:32 ` [PATCH 2/5] module: Remove unnecessary +1 from last_unloaded_module::name size Petr Pavlu
2025-07-16 19:49 ` Daniel Gomez
2025-06-30 14:32 ` [PATCH 3/5] module: Restore the moduleparam prefix length check Petr Pavlu
2025-07-17 19:23 ` Daniel Gomez
2025-07-21 9:21 ` Petr Pavlu
2025-07-28 6:43 ` Daniel Gomez
2025-06-30 14:32 ` [PATCH 4/5] tracing: Replace MAX_PARAM_PREFIX_LEN with MODULE_NAME_LEN Petr Pavlu
2025-07-28 6:48 ` Daniel Gomez
2025-07-28 14:34 ` Steven Rostedt
2025-06-30 14:32 ` [PATCH 5/5] module: Rename MAX_PARAM_PREFIX_LEN to __MODULE_NAME_LEN Petr Pavlu
2025-07-28 6:48 ` Daniel Gomez [this message]
2025-07-31 12:03 ` [PATCH 0/5] module: Fix minor problems related to MODULE_NAME_LEN Daniel Gomez
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=93b81672-0604-42d1-8a10-0fc88ba2efd6@kernel.org \
--to=da.gomez@kernel.org \
--cc=da.gomez@samsung.com \
--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®