Skip to contentSkip to conversation

sys_init_module refuses to load module without init code/data sections

PATCH In review Juan M. de la Torre 2 participants 2 messages Nov 19, 2002 – Nov 20, 2002

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sys_init_module refuses to load module without init code/data sections

load_module() stores in mod->init_size the size of init data and init
code sections, and later allocs (using module_alloc()) mod->init_size bytes.

If the module has not init data and init code sections mod->init_size
is 0, so module_alloc() will return NULL and load_module() will abort loading the module with -ENOMEM.

Possible patch attached, sorry if this is a known issue.

Best regards,
Juanma

kernel/module.c Tue Nov 19 20:37:47 2002 renamed from kernel/module.c.orig Tue Nov 19 20:08:52 2002 +9 -7
@@ -972,13 +972,15 @@
        memset(ptr, 0, mod->core_size);
        mod->module_core = ptr;
 
-       ptr = module_alloc(mod->init_size);
-       if (!ptr) {
-               err = -ENOMEM;
-               goto free_core;
-       }
-       memset(ptr, 0, mod->init_size);
-       mod->module_init = ptr;
+       if (mod->init_size) {
+               ptr = module_alloc(mod->init_size);
+               if (!ptr) {
+                       err = -ENOMEM;
+                       goto free_core;
+               }
+               memset(ptr, 0, mod->init_size);
+               mod->module_init = ptr;
+       }
 
        /* Transfer each section which requires ALLOC, and set sh_offset
           fields to absolute addresses. */
Signature · 1 line
/jm
#1 lore raw

In message <20021119193857.GA406@apocalipsis> you write:

Quoted 4 lines

load_module() stores in mod->init_size the size of init data and init
code sections, and later allocs (using module_alloc()) mod->init_size bytes.

Yep, fix already sent to Linus.

Thanks,
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.