x86/its: Fix build errors when CONFIG_MODULES=n
Subsystems (2)
PATCH 1/1 x86/its: Fix build errors when CONFIG_MODULES=n
From: Eric Biggers <[email protected]>
Fix several build errors when CONFIG_MODULES=n, including the following:
../arch/x86/kernel/alternative.c:195:25: error: incomplete definition of type 'struct module'
195 | for (int i = 0; i < mod->its_num_pages; i++) {
--- arch/x86/kernel/alternative.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/x86/kernel/alternative.c +6 -0
@@ -131,11 +131,13 @@ const unsigned char * const x86_nops[ASM_NOP_MAX+1] =static bool cfi_paranoid__ro_after_init ;#endif #ifdef CONFIG_MITIGATION_ITS +#ifdef CONFIG_MODULES static struct module *its_mod; +#endif static void *its_page;static unsigned int its_offset;/* Initialize a thunk with the "jmp *reg; int3" instructions. */ static void *its_init_thunk (void *thunk,int reg)
@@ -169,10 +171,11 @@ static void *its_init_thunk(void *thunk, int reg) bytes[i++] =0xcc ;return thunk + offset; } +#ifdef CONFIG_MODULES void its_init_mod (struct module *mod) {if (!cpu_feature_enabled (X86_FEATURE_INDIRECT_THUNK_ITS ))return ;
@@ -207,18 +210,20 @@ void its_free_mod(struct module *mod)void *page = mod->its_page_array[i]; execmem_free(page); }kfree (mod->its_page_array); } +#endif /* CONFIG_MODULES */ static void *its_alloc (void ) { void *page __free(execmem) = execmem_alloc(EXECMEM_MODULE_TEXT, PAGE_SIZE);if (!page)return NULL ; +#ifdef CONFIG_MODULES if (its_mod) {void *tmp =krealloc (its_mod->its_page_array, (its_mod->its_num_pages+1 ) *sizeof (void *),GFP_KERNEL );if (!tmp)
@@ -227,10 +232,11 @@ static void *its_alloc(void) its_mod->its_page_array = tmp; its_mod->its_page_array[its_mod->its_num_pages++] = page; execmem_make_temp_rw(page, PAGE_SIZE); } +#endif /* CONFIG_MODULES */ return no_free_ptr (page); }static void *its_allocate_thunk (int reg)
base-commit: 627277ba7c2398dc4f95cc9be8222bb2d9477800
Signature · 1 line
2.49.0
Quoted 7 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Fix several build errors when
CONFIG_MODULES=n, including the following:
../arch/x86/kernel/alternative.c:195:25: error: incomplete definition of type 'struct module'
195 | for (int i = 0; i <mod->its_num_pages; i++) {
Quoted 7 lines
Fixes 872df34d7c51 ("x86/its: Use dynamic thunks for indirect branches")Signed-off-by Eric Biggers <[email protected]>--- arch/x86/kernel/alternative.c | 6 ++++++ 1 file changed, 6 insertions(+)
alex.
Quoted 65 lines
arch/x86/kernel/alternative.c +6
-0@@ -131,11 +131,13 @@ const unsigned char * const x86_nops[ASM_NOP_MAX+1] =static bool cfi_paranoid__ro_after_init ;#endif #ifdef CONFIG_MITIGATION_ITS +#ifdef CONFIG_MODULES static struct module *its_mod; +#endif static void *its_page;static unsigned int its_offset;/* Initialize a thunk with the "jmp *reg; int3" instructions. */ static void *its_init_thunk (void *thunk,int reg)@@ -169,10 +171,11 @@ static void *its_init_thunk(void *thunk, int reg) bytes[i++] =0xcc ;return thunk + offset; } +#ifdef CONFIG_MODULES void its_init_mod (struct module *mod) {if (!cpu_feature_enabled (X86_FEATURE_INDIRECT_THUNK_ITS ))return ;@@ -207,18 +210,20 @@ void its_free_mod(struct module *mod)void *page = mod->its_page_array[i]; execmem_free(page); }kfree (mod->its_page_array); } +#endif /* CONFIG_MODULES */ static void *its_alloc (void ) { void *page __free(execmem) = execmem_alloc(EXECMEM_MODULE_TEXT, PAGE_SIZE);if (!page)return NULL ; +#ifdef CONFIG_MODULES if (its_mod) {void *tmp =krealloc (its_mod->its_page_array, (its_mod->its_num_pages+1 ) *sizeof (void *),GFP_KERNEL );if (!tmp)@@ -227,10 +232,11 @@ static void *its_alloc(void) its_mod->its_page_array = tmp; its_mod->its_page_array[its_mod->its_num_pages++] = page; execmem_make_temp_rw(page, PAGE_SIZE); } +#endif /* CONFIG_MODULES */ return no_free_ptr (page); }static void *its_allocate_thunk (int reg)base-commit:
627277ba7c2398dc4f95cc9be8222bb2d9477800
Quoted 11 lines · On Mon, 12 May 2025 19:58:39 -0700 Eric Biggers <[email protected]> wrote:
From: Eric Biggers <[email protected]>
Fix several build errors when
CONFIG_MODULES=n, including the following:
../arch/x86/kernel/alternative.c:195:25: error: incomplete definition of type 'struct module'
195 | for (int i = 0; i <mod->its_num_pages; i++) {Fixes 872df34d7c51 ("x86/its: Use dynamic thunks for indirect branches")Signed-off-by Eric Biggers <[email protected]>---
I just hit this build failure while running tests on patches that are on top of tip/master.
-- Steve
Quoted 2 lines · On Mon, 12 May 2025 19:58:39 -0700 Eric Biggers <[email protected]> wrote:
Fixes 872df34d7c51 ("x86/its: Use dynamic thunks for indirect branches")
No need to Cc stable. This isn't even in Linus's tree.
-- Steve
Quoted 1 line
Signed-off-by Eric Biggers <[email protected]>
Hi Steven,
Quoted 7 lines · Steven Rostedt
Quoted 2 lines · On Mon, 12 May 2025 19:58:39 -0700 Eric Biggers <[email protected]> wrote:
Fixes 872df34d7c51 ("x86/its: Use dynamic thunks for indirect branches")No need to Cc stable. This isn't even in Linus's tree.
It is now(today) present I think: https://github.com/torvalds/linux/commit/872df34d7c51a79523820ea6a14860398c639b87
Greg queued this up for today's stable-rc which was released for Testing.
Informed him about this fix:
https://lore.kernel.org/all/[email protected]/
Thanks,
Harshit
Quoted 4 lines
-- Steve
Quoted 1 line
Signed-off-by Eric Biggers <[email protected]>
Quoted 7 lines · On Wed, 14 May 2025 00:53:26 +0530 Harshit Mogalapalli…
Hi Steven,
Quoted 3 lines · Steven Rostedt
On Mon, 12 May 2025 19:58:39 -0700
Eric Biggers <[email protected]> wrote:
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Fixes 872df34d7c51 ("x86/its: Use dynamic thunks for indirect branches")No need to Cc stable. This isn't even in Linus's tree.
It is now(today) present I think:
https://github.com/torvalds/linux/commit/872df34d7c51a79523820ea6a14860398c639b87
Bah. My upstream repo gets updated every night via a cronjob, and that's what I was looking at.
Quoted 2 lines
Greg queued this up for today's stable-rc which was released for Testing.
I didn't see any "stable" or "fixes" tag in the offending commit, so I definitely didn't expect it to be in stable :-p
Quoted 4 lines
Informed him about this fix:
Thanks for letting me know.
-- Steve
Quoted 6 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Fix several build errors when
CONFIG_MODULES=n, including the following:
../arch/x86/kernel/alternative.c:195:25: error: incomplete definition of type 'struct module'
195 | for (int i = 0; i <mod->its_num_pages; i++) {
Thanks for sending this:
Quoted 7 lines · Dave Hansen
Quoted 6 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Fix several build errors when
CONFIG_MODULES=n, including the following:
../arch/x86/kernel/alternative.c:195:25: error: incomplete definition of type 'struct module'
195 | for (int i = 0; i <mod->its_num_pages; i++) {
Linus, could you pick this one up directly, please? The thread has acks from a few folks already.
The normal x86/urgent branch doesn't have this bug yet and I don't want to merge the existing pile of fixes with your tree at a completely random point.
Oh, and you called it ... "done without public testing" strikes again.
Quoted 2 lines · Dave Hansen
Linus, could you pick this one up directly, please?
Done. Thanks,
Linus