module: fix clang CFI with MODULE_UNLOAD=n
authorArnd Bergmann <arnd@arndb.de>
Mon, 27 Sep 2021 12:15:10 +0000 (14:15 +0200)
committerJessica Yu <jeyu@kernel.org>
Tue, 28 Sep 2021 10:56:26 +0000 (12:56 +0200)
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")
Acked-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jessica Yu <jeyu@kernel.org>
kernel/module.c

index 40ec9a030eecf41d5597e6c910746aab385b1da0..5c26a76e800b579a1e450b1aab962da2df7fc0d6 100644 (file)
@@ -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