Skip to content

Commit c1f47eb

Browse files
committed
Merge tag 'modules-for-v5.13-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux
Pull module fix from Jessica Yu: "When CONFIG_MODULE_UNLOAD=n, module exit sections get sorted into the init region of the module in order to satisfy the requirements of jump_labels and static_calls. Previously, the exit section check was done in module_init_section(), but the solution there is not completely arch-indepedent as ARM is a special case and supplies its own module_init_section() function. Instead of pushing this logic further to the arch-specific code, switch to an arch-independent solution to check for module exit sections in the core module loader code in layout_sections() instead" * tag 'modules-for-v5.13-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux: module: check for exit sections in layout_sections() instead of module_init_section()
2 parents 93bb533 + 055f23b commit c1f47eb

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

kernel/module.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2401,6 +2401,15 @@ static long get_offset(struct module *mod, unsigned int *size,
24012401
return ret;
24022402
}
24032403

2404+
static bool module_init_layout_section(const char *sname)
2405+
{
2406+
#ifndef CONFIG_MODULE_UNLOAD
2407+
if (module_exit_section(sname))
2408+
return true;
2409+
#endif
2410+
return module_init_section(sname);
2411+
}
2412+
24042413
/*
24052414
* Lay out the SHF_ALLOC sections in a way not dissimilar to how ld
24062415
* might -- code, read-only data, read-write data, small data. Tally
@@ -2435,7 +2444,7 @@ static void layout_sections(struct module *mod, struct load_info *info)
24352444
if ((s->sh_flags & masks[m][0]) != masks[m][0]
24362445
|| (s->sh_flags & masks[m][1])
24372446
|| s->sh_entsize != ~0UL
2438-
|| module_init_section(sname))
2447+
|| module_init_layout_section(sname))
24392448
continue;
24402449
s->sh_entsize = get_offset(mod, &mod->core_layout.size, s, i);
24412450
pr_debug("\t%s\n", sname);
@@ -2468,7 +2477,7 @@ static void layout_sections(struct module *mod, struct load_info *info)
24682477
if ((s->sh_flags & masks[m][0]) != masks[m][0]
24692478
|| (s->sh_flags & masks[m][1])
24702479
|| s->sh_entsize != ~0UL
2471-
|| !module_init_section(sname))
2480+
|| !module_init_layout_section(sname))
24722481
continue;
24732482
s->sh_entsize = (get_offset(mod, &mod->init_layout.size, s, i)
24742483
| INIT_OFFSET_MASK);
@@ -2807,11 +2816,7 @@ void * __weak module_alloc(unsigned long size)
28072816

28082817
bool __weak module_init_section(const char *name)
28092818
{
2810-
#ifndef CONFIG_MODULE_UNLOAD
2811-
return strstarts(name, ".init") || module_exit_section(name);
2812-
#else
28132819
return strstarts(name, ".init");
2814-
#endif
28152820
}
28162821

28172822
bool __weak module_exit_section(const char *name)

0 commit comments

Comments
 (0)