Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

execmem: drop writable parameter from execmem_fill_trapping_insns()

After update of execmem_cache_free() that made memory writable before
updating it, there is no need to update read only memory, so the writable
parameter to execmem_fill_trapping_insns() is not needed. Drop it.

Link: https://lkml.kernel.org/r/20250713071730.4117334-7-rppt@kernel.org
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Daniel Gomez <da.gomez@samsung.com>
Cc: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Cc: Petr Pavlu <petr.pavlu@suse.com>
Cc: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Mike Rapoport (Microsoft) and committed by
Andrew Morton
ab674b68 3bd4e0ac

+5 -10
+2 -6
arch/x86/mm/init.c
··· 1063 1063 static struct execmem_info execmem_info __ro_after_init; 1064 1064 1065 1065 #ifdef CONFIG_ARCH_HAS_EXECMEM_ROX 1066 - void execmem_fill_trapping_insns(void *ptr, size_t size, bool writeable) 1066 + void execmem_fill_trapping_insns(void *ptr, size_t size) 1067 1067 { 1068 - /* fill memory with INT3 instructions */ 1069 - if (writeable) 1070 - memset(ptr, INT3_INSN_OPCODE, size); 1071 - else 1072 - text_poke_set(ptr, INT3_INSN_OPCODE, size); 1068 + memset(ptr, INT3_INSN_OPCODE, size); 1073 1069 } 1074 1070 #endif 1075 1071
+1 -2
include/linux/execmem.h
··· 60 60 * will trap 61 61 * @ptr: pointer to memory to fill 62 62 * @size: size of the range to fill 63 - * @writable: is the memory poited by @ptr is writable or ROX 64 63 * 65 64 * A hook for architecures to fill execmem ranges with invalid instructions. 66 65 * Architectures that use EXECMEM_ROX_CACHE must implement this. 67 66 */ 68 - void execmem_fill_trapping_insns(void *ptr, size_t size, bool writable); 67 + void execmem_fill_trapping_insns(void *ptr, size_t size); 69 68 70 69 /** 71 70 * execmem_restore_rox - restore read-only-execute permissions
+2 -2
mm/execmem.c
··· 304 304 goto err_free_mem; 305 305 306 306 /* fill memory with instructions that will trap */ 307 - execmem_fill_trapping_insns(p, alloc_size, /* writable = */ true); 307 + execmem_fill_trapping_insns(p, alloc_size); 308 308 309 309 err = set_memory_rox((unsigned long)p, vm->nr_pages); 310 310 if (err) ··· 363 363 if (err) 364 364 return err; 365 365 366 - execmem_fill_trapping_insns(ptr, size, /* writable = */ true); 366 + execmem_fill_trapping_insns(ptr, size); 367 367 execmem_restore_rox(ptr, size); 368 368 369 369 err = execmem_cache_add_locked(ptr, size, gfp_mask);