Skip to content

Commit 888b5a8

Browse files
rpptakpm00
authored andcommitted
execmem: move execmem_force_rw() and execmem_restore_rox() before use
to avoid static declarations. Link: https://lkml.kernel.org/r/20250713071730.4117334-5-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 187fd85 commit 888b5a8

1 file changed

Lines changed: 21 additions & 23 deletions

File tree

mm/execmem.c

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,27 @@ static int execmem_set_direct_map_valid(struct vm_struct *vm, bool valid)
137137
return err;
138138
}
139139

140+
static int execmem_force_rw(void *ptr, size_t size)
141+
{
142+
unsigned int nr = PAGE_ALIGN(size) >> PAGE_SHIFT;
143+
unsigned long addr = (unsigned long)ptr;
144+
int ret;
145+
146+
ret = set_memory_nx(addr, nr);
147+
if (ret)
148+
return ret;
149+
150+
return set_memory_rw(addr, nr);
151+
}
152+
153+
int execmem_restore_rox(void *ptr, size_t size)
154+
{
155+
unsigned int nr = PAGE_ALIGN(size) >> PAGE_SHIFT;
156+
unsigned long addr = (unsigned long)ptr;
157+
158+
return set_memory_rox(addr, nr);
159+
}
160+
140161
static void execmem_cache_clean(struct work_struct *work)
141162
{
142163
struct maple_tree *free_areas = &execmem_cache.free_areas;
@@ -328,8 +349,6 @@ static inline void *pending_free_clear(void *ptr)
328349
return (void *)((unsigned long)ptr & ~PENDING_FREE_MASK);
329350
}
330351

331-
static int execmem_force_rw(void *ptr, size_t size);
332-
333352
static int __execmem_cache_free(struct ma_state *mas, void *ptr, gfp_t gfp_mask)
334353
{
335354
size_t size = mas_range_len(mas);
@@ -415,27 +434,6 @@ static bool execmem_cache_free(void *ptr)
415434
return true;
416435
}
417436

418-
static int execmem_force_rw(void *ptr, size_t size)
419-
{
420-
unsigned int nr = PAGE_ALIGN(size) >> PAGE_SHIFT;
421-
unsigned long addr = (unsigned long)ptr;
422-
int ret;
423-
424-
ret = set_memory_nx(addr, nr);
425-
if (ret)
426-
return ret;
427-
428-
return set_memory_rw(addr, nr);
429-
}
430-
431-
int execmem_restore_rox(void *ptr, size_t size)
432-
{
433-
unsigned int nr = PAGE_ALIGN(size) >> PAGE_SHIFT;
434-
unsigned long addr = (unsigned long)ptr;
435-
436-
return set_memory_rox(addr, nr);
437-
}
438-
439437
#else /* CONFIG_ARCH_HAS_EXECMEM_ROX */
440438
/*
441439
* when ROX cache is not used the permissions defined by architectures for

0 commit comments

Comments
 (0)