Thread (13 messages) 13 messages, 4 authors, 2025-07-12

Re: [PATCH v2 2/8] execmem: introduce execmem_alloc_rw()

From: Daniel Gomez <da.gomez@kernel.org>
Date: 2025-07-11 14:29:54
Also in: linux-mm, linux-modules, lkml

On 09/07/2025 15.49, Mike Rapoport wrote:
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>

Some callers of execmem_alloc() require the memory to be temporarily
writable even when it is allocated from ROX cache. These callers use
execemem_make_temp_rw() right after the call to execmem_alloc().

Wrap this sequence in execmem_alloc_rw() API.

Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Reviewed-by: Daniel Gomez <redacted>
quoted hunk ↗ jump to hunk
---
diff --git a/mm/execmem.c b/mm/execmem.c
index 0712ebb4eb77..6b040fbc5f4f 100644
--- a/mm/execmem.c
+++ b/mm/execmem.c
{...}
quoted hunk ↗ jump to hunk
@@ -387,6 +397,21 @@ void *execmem_alloc(enum execmem_type type, size_t size)
 	return kasan_reset_tag(p);
 }
 
+void *execmem_alloc_rw(enum execmem_type type, size_t size)
+{
+	void *p __free(execmem) = execmem_alloc(type, size);
+	int err;
+
+	if (!p)
+		return NULL;
+
+	err = execmem_force_rw(p, size);
+	if (err)
+		return NULL;
You don't need to save the error here. That, allows err declaration to be
dropped.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help