Skip to content

Commit ab674b6

Browse files
rpptakpm00
authored andcommitted
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>
1 parent 3bd4e0a commit ab674b6

3 files changed

Lines changed: 5 additions & 10 deletions

File tree

arch/x86/mm/init.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,13 +1063,9 @@ unsigned long arch_max_swapfile_size(void)
10631063
static struct execmem_info execmem_info __ro_after_init;
10641064

10651065
#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)
10671067
{
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);
10731069
}
10741070
#endif
10751071

include/linux/execmem.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,11 @@ enum execmem_range_flags {
6060
* will trap
6161
* @ptr: pointer to memory to fill
6262
* @size: size of the range to fill
63-
* @writable: is the memory poited by @ptr is writable or ROX
6463
*
6564
* A hook for architecures to fill execmem ranges with invalid instructions.
6665
* Architectures that use EXECMEM_ROX_CACHE must implement this.
6766
*/
68-
void execmem_fill_trapping_insns(void *ptr, size_t size, bool writable);
67+
void execmem_fill_trapping_insns(void *ptr, size_t size);
6968

7069
/**
7170
* execmem_restore_rox - restore read-only-execute permissions

mm/execmem.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ static int execmem_cache_populate(struct execmem_range *range, size_t size)
304304
goto err_free_mem;
305305

306306
/* 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);
308308

309309
err = set_memory_rox((unsigned long)p, vm->nr_pages);
310310
if (err)
@@ -363,7 +363,7 @@ static int __execmem_cache_free(struct ma_state *mas, void *ptr, gfp_t gfp_mask)
363363
if (err)
364364
return err;
365365

366-
execmem_fill_trapping_insns(ptr, size, /* writable = */ true);
366+
execmem_fill_trapping_insns(ptr, size);
367367
execmem_restore_rox(ptr, size);
368368

369369
err = execmem_cache_add_locked(ptr, size, gfp_mask);

0 commit comments

Comments
 (0)