Thread (15 messages) 15 messages, 4 authors, 2025-01-29

Re: [PATCH v3 6/9] module: switch to execmem API for remapping as RW and restoring ROX

From: Petr Pavlu <petr.pavlu@suse.com>
Date: 2025-01-27 12:50:35
Also in: linux-kselftest, linux-mm, linux-modules, linux-um, live-patching, lkml

On 1/26/25 08:47, Mike Rapoport wrote:
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>

Instead of using writable copy for module text sections, temporarily remap
the memory allocated from execmem's ROX cache as writable and restore its
ROX permissions after the module is formed.

This will allow removing nasty games with writable copy in alternatives
patching on x86.

Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
[...]
+static void module_memory_restore_rox(struct module *mod)
+{
+	for_class_mod_mem_type(type, text) {
+		struct module_memory *mem = &mod->mem[type];
+
+		if (mem->is_rox)
+			execmem_restore_rox(mem->base, mem->size);
+	}
+}
+
Can the execmem_restore_rox() call here fail? I realize that there isn't
much that the module loader can do if that happens, but should it be
perhaps logged as a warning?

-- 
Thanks,
Petr
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help