Skip to content

Comments

Properly handle module_kobject creation#57

Closed
modules-kpd-app[bot] wants to merge 8 commits intomodules-next_basefrom
series/931455=>modules-next
Closed

Properly handle module_kobject creation#57
modules-kpd-app[bot] wants to merge 8 commits intomodules-next_basefrom
series/931455=>modules-next

Conversation

@modules-kpd-app
Copy link

Pull request for series with
subject: Properly handle module_kobject creation
version: 3
url: https://patchwork.kernel.org/project/linux-modules/list/?series=932900

@modules-kpd-app
Copy link
Author

Upstream branch: 053842e
series: https://patchwork.kernel.org/project/linux-modules/list/?series=932900
version: 3

@modules-kpd-app
Copy link
Author

Upstream branch: afa9286
series: https://patchwork.kernel.org/project/linux-modules/list/?series=932900
version: 3

@modules-kpd-app modules-kpd-app bot force-pushed the series/931455=>modules-next branch from 1f6f33c to 70a4fb2 Compare February 17, 2025 10:02
@modules-kpd-app
Copy link
Author

Upstream branch: afa9286
series: https://patchwork.kernel.org/project/linux-modules/list/?series=938646
version: 4

@modules-kpd-app modules-kpd-app bot added V4 and removed V3 labels Feb 27, 2025
@modules-kpd-app modules-kpd-app bot force-pushed the series/931455=>modules-next branch from 70a4fb2 to c54844d Compare February 27, 2025 18:51
@modules-kpd-app
Copy link
Author

Upstream branch: 085c5e3
series: https://patchwork.kernel.org/project/linux-modules/list/?series=938646
version: 4

@modules-kpd-app modules-kpd-app bot force-pushed the series/931455=>modules-next branch from c54844d to 2542b04 Compare March 18, 2025 22:57
@modules-kpd-app modules-kpd-app bot force-pushed the modules-next_base branch from 7c2b408 to 2996654 Compare April 7, 2025 01:58
@modules-kpd-app
Copy link
Author

Upstream branch: 897c0b4
series: https://patchwork.kernel.org/project/linux-modules/list/?series=938646
version: 4

@modules-kpd-app modules-kpd-app bot force-pushed the series/931455=>modules-next branch from 2542b04 to 9cbb9f7 Compare April 7, 2025 02:00
petrpavlu and others added 4 commits April 7, 2025 16:08
Minor cleanup, this is a non-functional change.

Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Link: https://lore.kernel.org/r/20250306131430.7016-2-petr.pavlu@suse.com
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
Move the logic to mark special sections as read-only after module
initialization into a separate function, along other related code in
strict_rwx.c. Use a table with names of such sections to make it easier to
add more.

Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Link: https://lore.kernel.org/r/20250306131430.7016-3-petr.pavlu@suse.com
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
Section .static_call_sites holds data structures that need to be sorted and
processed only at module load time. This initial processing happens in
static_call_add_module(), which is invoked as a callback to the
MODULE_STATE_COMING notification from prepare_coming_module().

The section is never modified afterwards. Make it therefore read-only after
module initialization to avoid any (non-)accidental modifications.

Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Link: https://lore.kernel.org/r/20250306131430.7016-4-petr.pavlu@suse.com
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
@modules-kpd-app modules-kpd-app bot force-pushed the modules-next_base branch from 2996654 to d4037eb Compare April 7, 2025 14:12
Shyam Saini added 4 commits April 7, 2025 14:14
The locate_module_kobject() function looks up an existing
module_kobject for a given module name. If it cannot find the
corresponding module_kobject, it creates one for the given name.

This commit renames locate_module_kobject() to
lookup_or_create_module_kobject() to better describe its operations.

This doesn't change anything functionality wise.

Fixes: 96a1a24 ("kernel/params.c: defer most of param_sysfs_init() to late_initcall time")
Cc: stable@kernel.org
Suggested-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Shyam Saini <shyamsaini@linux.microsoft.com>
In the unlikely event of the allocation failing, it is better to let
the machine boot with a not fully populated sysfs than to kill it with
this BUG_ON(). All callers are already prepared for
lookup_or_create_module_kobject() returning NULL.

This is also preparation for calling this function from non __init
code, where using BUG_ON for allocation failure handling is not
acceptable.

Since we are here, also start using IS_ENABLED instead of #ifdef
construct.

Fixes: 96a1a24 ("kernel/params.c: defer most of param_sysfs_init() to late_initcall time")
Cc: stable@kernel.org
Suggested-by: Thomas Weißschuh <linux@weissschuh.net>
Suggested-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Shyam Saini <shyamsaini@linux.microsoft.com>
lookup_or_create_module_kobject() is marked as static and __init,
to make it global drop static keyword.
Since this function can be called from non-init code, use __modinit
instead of __init, __modinit marker will make it __init if
CONFIG_MODULES is not defined.

Fixes: 96a1a24 ("kernel/params.c: defer most of param_sysfs_init() to late_initcall time")
Cc: stable@kernel.org
Suggested-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Shyam Saini <shyamsaini@linux.microsoft.com>
module_add_driver() relies on module_kset list for
/sys/module/<built-in-module>/drivers directory creation.

Since,
commit 96a1a24 ("kernel/params.c: defer most of param_sysfs_init() to late_initcall time")
drivers which are initialized from subsys_initcall() or any other
higher precedence initcall couldn't find the related kobject entry
in the module_kset list because module_kset is not fully populated
by the time module_add_driver() refers it. As a consequence,
module_add_driver() returns early without calling make_driver_name().
Therefore, /sys/module/<built-in-module>/drivers is never created.

Fix this issue by letting module_add_driver() handle module_kobject
creation itself.

Fixes: 96a1a24 ("kernel/params.c: defer most of param_sysfs_init() to late_initcall time")
Cc: stable@kernel.org
Suggested-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Shyam Saini <shyamsaini@linux.microsoft.com>
@modules-kpd-app
Copy link
Author

Upstream branch: b464e57
series: https://patchwork.kernel.org/project/linux-modules/list/?series=938646
version: 4

@modules-kpd-app modules-kpd-app bot force-pushed the series/931455=>modules-next branch from 9cbb9f7 to f76c067 Compare April 7, 2025 14:14
@modules-kpd-app modules-kpd-app bot force-pushed the modules-next_base branch from d4037eb to 39f16b8 Compare May 5, 2025 08:22
@modules-kpd-app modules-kpd-app bot force-pushed the modules-next_base branch from 39f16b8 to d6fb02c Compare May 18, 2025 12:05
@modules-kpd-app
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/linux-modules/list/?series=938646 irrelevant now. Closing PR.

@modules-kpd-app modules-kpd-app bot added accepted and removed new labels May 18, 2025
@modules-kpd-app modules-kpd-app bot closed this May 18, 2025
@modules-kpd-app modules-kpd-app bot deleted the series/931455=>modules-next branch May 18, 2025 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant