2021-09-27 12:17:26

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH] 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")
Signed-off-by: Arnd Bergmann <[email protected]>
---
kernel/module.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/kernel/module.c b/kernel/module.c
index 40ec9a030eec..5c26a76e800b 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -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
--
2.29.2


2021-09-27 13:38:14

by Miroslav Benes

[permalink] [raw]
Subject: Re: [PATCH] module: fix clang CFI with MODULE_UNLOAD=n

On Mon, 27 Sep 2021, Arnd Bergmann wrote:

> 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")
> Signed-off-by: Arnd Bergmann <[email protected]>

Reviewed-by: Miroslav Benes <[email protected]>

M

2021-09-27 15:28:56

by Sami Tolvanen

[permalink] [raw]
Subject: Re: [PATCH] module: fix clang CFI with MODULE_UNLOAD=n

Hi Arnd,

On Mon, Sep 27, 2021 at 5:15 AM Arnd Bergmann <[email protected]> wrote:
>
> 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")
> Signed-off-by: Arnd Bergmann <[email protected]>
> ---
> kernel/module.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/kernel/module.c b/kernel/module.c
> index 40ec9a030eec..5c26a76e800b 100644
> --- a/kernel/module.c
> +++ b/kernel/module.c
> @@ -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!

Reviewed-by: Sami Tolvanen <[email protected]>

Sami

2021-09-27 16:24:13

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH] module: fix clang CFI with MODULE_UNLOAD=n

On Mon, Sep 27, 2021 at 02:15:10PM +0200, Arnd Bergmann wrote:
> 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")
> Signed-off-by: Arnd Bergmann <[email protected]>

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

Acked-by: Kees Cook <[email protected]>

--
Kees Cook

2021-09-28 11:05:22

by Jessica Yu

[permalink] [raw]
Subject: Re: [PATCH] module: fix clang CFI with MODULE_UNLOAD=n

+++ Arnd Bergmann [27/09/21 14:15 +0200]:
>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")
>Signed-off-by: Arnd Bergmann <[email protected]>

Applied, thanks everyone!

Jessica