Skip to content

Commit ffb4ba7

Browse files
committed
[module] Don't let gcc inline load_module()
'load_module()' is a complex function that contains all the ELF section logic, and inlining it is utterly insane. But gcc will do it, simply because there is only one call-site. As a result, all the stack space that is allocated for all the work to load the module will still be active when we actually call the module init sequence, and the deep call chain makes stack overflows happen. And stack overflows are really hard to debug, because they not only corrupt random pages below the stack, but also corrupt the thread_info structure that is allocated under the stack. In this case, Alan Brunelle reported some crazy oopses at bootup, after loading the processor module that ends up doing complex ACPI stuff and has quite a deep callchain. This should fix it, and is the sane thing to do regardless. Cc: Alan D. Brunelle <Alan.Brunelle@hp.com> Cc: Arjan van de Ven <arjan@linux.intel.com> Cc: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 83097ac commit ffb4ba7

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎kernel/module.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1799,7 +1799,7 @@ static void *module_alloc_update_bounds(unsigned long size)
17991799

18001800
/* Allocate and load the module: note that size of section 0 is always
18011801
zero, and we rely on this for optional sections. */
1802-
static struct module *load_module(void __user *umod,
1802+
static noinline struct module *load_module(void __user *umod,
18031803
unsigned long len,
18041804
const char __user *uargs)
18051805
{

0 commit comments

Comments
 (0)