2024-05-06 06:28:07

by Joey Jiao

[permalink] [raw]
Subject: [PATCH] kernel/module: disable cfi for do_mod_ctors

CFI failure when both CONFIG_CONSTRUCTORS and CFI_CLANG enabled.

CFI failure at do_init_module+0x100/0x384 (target:
tsan.module_ctor+0x0/0xa98 [module_name_xx]; expected type: 0xa540670c)

Disable cfi for do_mod_ctors to avoid cfi check on mod->ctors[i]().

Signed-off-by: Joey Jiao <[email protected]>
---
kernel/module/main.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/kernel/module/main.c b/kernel/module/main.c
index e1e8a7a9d6c1..d51e63795637 100644
--- a/kernel/module/main.c
+++ b/kernel/module/main.c
@@ -2453,6 +2453,7 @@ static int post_relocation(struct module *mod, const struct load_info *info)
}

/* Call module constructors. */
+__nocfi
static void do_mod_ctors(struct module *mod)
{
#ifdef CONFIG_CONSTRUCTORS
--
2.43.2