History

Merge tag 'modules-for-v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux

Pull module updates from Jessica Yu: "Fix an age old bug involving jump_calls and static_labels when CONFIG_MODULE_UNLOAD=n. When CONFIG_MODULE_UNLOAD=n, it means you can't unload modules, so normally the __exit sections of a module are not loaded at all. However, dynamic code patching (jump_label, static_call, alternatives) can have sites in __exit sections even if __exit is never executed. Reported by Peter Zijlstra: 'Alternatives, jump_labels and static_call all can have relocations into __exit code. Not loading it at all would be BAD.' Therefore, load the __exit sections even when CONFIG_MODULE_UNLOAD=n, and discard them after init" * tag 'modules-for-v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux: module: treat exit sections the same as init sections when !CONFIG_MODULE_UNLOAD

Linus Torvalds committed 5 years ago

Commit 65c61de2 parents c70a4be 33121341 file · +4 −5Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/module.c+4−5
@@ -2807,7 +2807,11 @@ void * __weak module_alloc(unsigned long size) · 2806 unmodified lines
2807 2807
2808bool __weak module_init_section(const char *name)2808bool __weak module_init_section(const char *name)
2809{2809{
2810#ifndef CONFIG_MODULE_UNLOAD
2811 return strstarts(name, ".init") || module_exit_section(name);
2812#else
2810 return strstarts(name, ".init");2813 return strstarts(name, ".init");
2814#endif
2811}2815}
2812 2816
2813bool __weak module_exit_section(const char *name)2817bool __weak module_exit_section(const char *name)
@@ -3121,11 +3125,6 @@ static int rewrite_section_headers(struct load_info *info, int flags) · 307 unmodified lines
3121 */3125 */
3122 shdr->sh_addr = (size_t)info->hdr + shdr->sh_offset;3126 shdr->sh_addr = (size_t)info->hdr + shdr->sh_offset;
3123 3127
3124#ifndef CONFIG_MODULE_UNLOAD
3125 /* Don't load .exit sections */
3126 if (module_exit_section(info->secstrings+shdr->sh_name))
3127 shdr->sh_flags &= ~(unsigned long)SHF_ALLOC;
3128#endif
3129 }3128 }
3130 3129
3131 /* Track but don't keep modinfo and version sections. */3130 /* Track but don't keep modinfo and version sections. */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t