Properly handle module_kobject creation#57
Properly handle module_kobject creation#57modules-kpd-app[bot] wants to merge 8 commits intomodules-next_basefrom
Conversation
|
Upstream branch: 053842e |
95973fc to
b5b7508
Compare
|
Upstream branch: afa9286 |
1f6f33c to
70a4fb2
Compare
|
Upstream branch: afa9286 |
70a4fb2 to
c54844d
Compare
b5b7508 to
96f6e22
Compare
|
Upstream branch: 085c5e3 |
c54844d to
2542b04
Compare
96f6e22 to
7c2b408
Compare
7c2b408 to
2996654
Compare
|
Upstream branch: 897c0b4 |
2542b04 to
9cbb9f7
Compare
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>
2996654 to
d4037eb
Compare
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>
|
Upstream branch: b464e57 |
9cbb9f7 to
f76c067
Compare
d4037eb to
39f16b8
Compare
39f16b8 to
d6fb02c
Compare
|
At least one diff in series https://patchwork.kernel.org/project/linux-modules/list/?series=938646 irrelevant now. Closing PR. |
Pull request for series with
subject: Properly handle module_kobject creation
version: 3
url: https://patchwork.kernel.org/project/linux-modules/list/?series=932900