Skip to contentSkip to conversation

module: fix clang CFI with MODULE_UNLOAD=n

PATCH Applied Arnd Bergmann 5 participants 5 messages Sep 27, 2021 – Sep 28, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 module: fix clang CFI with MODULE_UNLOAD=n

From: Arnd Bergmann <[email protected]>

When CONFIG_MODULE_UNLOAD is disabled, the module->exit member is not defined, causing a build failure:

kernel/module.c:4493:8: error: no member named 'exit' in 'struct module'

                mod->exit = *exit;

add an #ifdef block around this.

Fixes cf68fffb66d6 ("add support for Clang CFI")
---
 kernel/module.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/module.c +2 -0
index 40ec9a030eec..5c26a76e800b 100644
@@ -4489,8 +4489,10 @@ static void cfi_init(struct module *mod)
 	/* Fix init/exit functions to point to the CFI jump table */
 	if (init)
 		mod->init = *init;
+#ifdef CONFIG_MODULE_UNLOAD
 	if (exit)
 		mod->exit = *exit;
+#endif
 
 	cfi_module_add(mod, module_addr_min);
 #endif
Signature · 1 line
2.29.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

When CONFIG_MODULE_UNLOAD is disabled, the module->exit member is not defined, causing a build failure:

Quoted 7 lines

kernel/module.c:4493:8: error: no member named 'exit' in 'struct module'

                mod->exit = *exit;

add an #ifdef block around this.

Fixes cf68fffb66d6 ("add support for Clang CFI")

M

Reviewed-by on v1 1/1
#2 lore raw
In reply to Arnd Bergmann

Hi Arnd,

Quoted 22 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

When CONFIG_MODULE_UNLOAD is disabled, the module->exit member is not defined, causing a build failure:

kernel/module.c:4493:8: error: no member named 'exit' in 'struct module'

                mod->exit = *exit;

add an #ifdef block around this.

Fixes cf68fffb66d6 ("add support for Clang CFI")
---
 kernel/module.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/module.c +0 -0
index 40ec9a030eec..5c26a76e800b 100644

kernel/module.c static void cfi_init(struct module *mod) · line 4498

Quoted 10 lines
kernel/module.c +2 -0
@@ -4489,8 +4489,10 @@ static void cfi_init(struct module *mod)
        /* Fix init/exit functions to point to the CFI jump table */
        if (init)
                mod->init = *init;
+#ifdef CONFIG_MODULE_UNLOAD
        if (exit)
                mod->exit = *exit;
+#endif
 
        cfi_module_add(mod, module_addr_min);
 #endif

Thanks for the fix!

Sami

Acked-by on v1 1/1
#3 lore raw
In reply to Arnd Bergmann
Quoted 5 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

When CONFIG_MODULE_UNLOAD is disabled, the module->exit member is not defined, causing a build failure:

Quoted 7 lines

kernel/module.c:4493:8: error: no member named 'exit' in 'struct module'

                mod->exit = *exit;

add an #ifdef block around this.

Fixes cf68fffb66d6 ("add support for Clang CFI")

Nice catch; thanks! (Not a lot of config build that way it seems...)

Signature · 1 line
Kees Cook
Applied
#4 lore raw
In reply to Arnd Bergmann

+++ Arnd Bergmann [27/09/21 14:15 +0200]:

Quoted 5 lines

From: Arnd Bergmann <[email protected]>

When CONFIG_MODULE_UNLOAD is disabled, the module->exit member is not defined, causing a build failure:

Quoted 7 lines

kernel/module.c:4493:8: error: no member named 'exit' in 'struct module'

               mod->exit = *exit;

add an #ifdef block around this.

Fixes cf68fffb66d6 ("add support for Clang CFI")

Applied, thanks everyone!

Jessica