]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
execmem: drop writable parameter from execmem_fill_trapping_insns()
authorMike Rapoport (Microsoft) <rppt@kernel.org>
Sun, 13 Jul 2025 07:17:28 +0000 (10:17 +0300)
committerAndrew Morton <akpm@linux-foundation.org>
Sat, 2 Aug 2025 19:06:12 +0000 (12:06 -0700)
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>
arch/x86/mm/init.c
include/linux/execmem.h
mm/execmem.c

index 7456df985d968cddbab519acec3a51be20c23af0..dbc63f0d538f046628d8a320bad27961d20599ff 100644 (file)
@@ -1063,13 +1063,9 @@ unsigned long arch_max_swapfile_size(void)
 static struct execmem_info execmem_info __ro_after_init;
 
 #ifdef CONFIG_ARCH_HAS_EXECMEM_ROX
-void execmem_fill_trapping_insns(void *ptr, size_t size, bool writeable)
+void execmem_fill_trapping_insns(void *ptr, size_t size)
 {
-       /* fill memory with INT3 instructions */
-       if (writeable)
-               memset(ptr, INT3_INSN_OPCODE, size);
-       else
-               text_poke_set(ptr, INT3_INSN_OPCODE, size);
+       memset(ptr, INT3_INSN_OPCODE, size);
 }
 #endif
 
index 8b61b05da7d57a1e824227a26241a0966ee8970a..7de229134e3071648f54cbd07243f4decd4eb2ee 100644 (file)
@@ -60,12 +60,11 @@ enum execmem_range_flags {
  *                              will trap
  * @ptr:       pointer to memory to fill
  * @size:      size of the range to fill
- * @writable:  is the memory poited by @ptr is writable or ROX
  *
  * A hook for architecures to fill execmem ranges with invalid instructions.
  * Architectures that use EXECMEM_ROX_CACHE must implement this.
  */
-void execmem_fill_trapping_insns(void *ptr, size_t size, bool writable);
+void execmem_fill_trapping_insns(void *ptr, size_t size);
 
 /**
  * execmem_restore_rox - restore read-only-execute permissions
index 9abf76a63a791434879911345c979564573a4502..1785d7f435e44d7af3528dbedbf6f34aa0fc627a 100644 (file)
@@ -304,7 +304,7 @@ static int execmem_cache_populate(struct execmem_range *range, size_t size)
                goto err_free_mem;
 
        /* fill memory with instructions that will trap */
-       execmem_fill_trapping_insns(p, alloc_size, /* writable = */ true);
+       execmem_fill_trapping_insns(p, alloc_size);
 
        err = set_memory_rox((unsigned long)p, vm->nr_pages);
        if (err)
@@ -363,7 +363,7 @@ static int __execmem_cache_free(struct ma_state *mas, void *ptr, gfp_t gfp_mask)
        if (err)
                return err;
 
-       execmem_fill_trapping_insns(ptr, size, /* writable = */ true);
+       execmem_fill_trapping_insns(ptr, size);
        execmem_restore_rox(ptr, size);
 
        err = execmem_cache_add_locked(ptr, size, gfp_mask);