[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250604104715.700149-1-nik.borisov@suse.com>
Date: Wed, 4 Jun 2025 13:47:15 +0300
From: Nikolay Borisov <nik.borisov@...e.com>
To: x86@...nel.org
Cc: pawan.kumar.gupta@...ux.intel.com,
peterz@...radead.org,
linux-kernel@...r.kernel.org,
dave.hansen@...ux.intel.com,
Nikolay Borisov <nik.borisov@...e.com>
Subject: [PATCH] x86/its: Always return a writable page for dynamic thunks
its_alloc unconditionally allocates and return a ROX page, but setting
it RW is predicated on its_mod being set. This can cause a #GP on the
memset in its_allocate_thunk() if its_mod is not set.
Since the function always returns a page, ensure it's always set
writable so it can be initialized properly.
Fixes: 872df34d7c51 ("x86/its: Use dynamic thunks for indirect branches")
Signed-off-by: Nikolay Borisov <nik.borisov@...e.com>
---
arch/x86/kernel/alternative.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index ecfe7b497cad..191e909636a5 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -199,6 +199,8 @@ static void *its_alloc(void)
if (!page)
return NULL;
+ execmem_make_temp_rw(page, PAGE_SIZE);
+
#ifdef CONFIG_MODULES
if (its_mod) {
void *tmp = krealloc(its_mod->its_page_array,
@@ -210,7 +212,6 @@ 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 */
--
2.43.0
Powered by blists - more mailing lists