From: Eric Biggers ebiggers@google.com
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") Cc: stable@vger.kernel.org Signed-off-by: Eric Biggers ebiggers@google.com --- arch/x86/kernel/alternative.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c index 48fd04e90114..45bcff181cba 100644 --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -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
On 5/13/25 04:58, Eric Biggers wrote:
From: Eric Biggers ebiggers@google.com
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") Cc: stable@vger.kernel.org Signed-off-by: Eric Biggers ebiggers@google.com
arch/x86/kernel/alternative.c | 6 ++++++ 1 file changed, 6 insertions(+)
Reviewed-by: Alexandre Chartre alexandre.chartre@oracle.com
alex.
diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c index 48fd04e90114..45bcff181cba 100644 --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -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
On Mon, 12 May 2025 19:58:39 -0700 Eric Biggers ebiggers@kernel.org wrote:
From: Eric Biggers ebiggers@google.com
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") Cc: stable@vger.kernel.org Signed-off-by: Eric Biggers ebiggers@google.com
I just hit this build failure while running tests on patches that are on top of tip/master.
Tested-by: Steven Rostedt (Google) rostedt@goodmis.org
-- Steve
On Mon, 12 May 2025 19:58:39 -0700 Eric Biggers ebiggers@kernel.org wrote:
Fixes: 872df34d7c51 ("x86/its: Use dynamic thunks for indirect branches") Cc: stable@vger.kernel.org
No need to Cc stable. This isn't even in Linus's tree.
-- Steve
Signed-off-by: Eric Biggers ebiggers@google.com
Hi Steven,
On 13/05/25 23:47, Steven Rostedt wrote:
On Mon, 12 May 2025 19:58:39 -0700 Eric Biggers ebiggers@kernel.org wrote:
Fixes: 872df34d7c51 ("x86/its: Use dynamic thunks for indirect branches") Cc: stable@vger.kernel.org
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/872df34d7c51a79523820ea6a14860398c6...
Greg queued this up for today's stable-rc which was released for Testing.
Informed him about this fix:
https://lore.kernel.org/all/88d537d6-57be-4fbc-9722-15997a022abb@oracle.com/
Thanks, Harshit
-- Steve
Signed-off-by: Eric Biggers ebiggers@google.com
On Wed, 14 May 2025 00:53:26 +0530 Harshit Mogalapalli harshit.m.mogalapalli@oracle.com wrote:
Hi Steven,
On 13/05/25 23:47, Steven Rostedt wrote:
On Mon, 12 May 2025 19:58:39 -0700 Eric Biggers ebiggers@kernel.org wrote:
Fixes: 872df34d7c51 ("x86/its: Use dynamic thunks for indirect branches") Cc: stable@vger.kernel.org
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/872df34d7c51a79523820ea6a14860398c6...
Bah. My upstream repo gets updated every night via a cronjob, and that's what I was looking at.
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
Informed him about this fix:
https://lore.kernel.org/all/88d537d6-57be-4fbc-9722-15997a022abb@oracle.com/
Thanks for letting me know.
-- Steve
On 5/12/25 19:58, Eric Biggers wrote:
From: Eric Biggers ebiggers@google.com
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:
Acked-by: Dave Hansen dave.hansen@intel.com
On 5/13/25 11:54, Dave Hansen wrote:
On 5/12/25 19:58, Eric Biggers wrote:
From: Eric Biggers ebiggers@google.com
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.
On Tue, 13 May 2025 at 13:32, Dave Hansen dave.hansen@intel.com wrote:
Linus, could you pick this one up directly, please?
Done. Thanks,
Linus
linux-stable-mirror@lists.linaro.org