diff options
| author | Peter Zijlstra <peterz@infradead.org> | 2025-02-14 12:32:04 +0300 |
|---|---|---|
| committer | Peter Zijlstra <peterz@infradead.org> | 2025-02-14 12:32:04 +0300 |
| commit | 92d2da37fdef65f9aeeb54c991df0cec524934ad (patch) | |
| tree | 38d3036f7f89f88d34eceda9cb2344c207ec7b97 /include/linux/execmem.h | |
| parent | a64dcfb451e254085a7daee5fe51bf22959d52d3 (diff) | |
| parent | 675204778c69c2b3e0f6a4e2dbfeb4f3e89194ba (diff) | |
| download | linux-92d2da37fdef65f9aeeb54c991df0cec524934ad.tar.xz | |
Merge branch 'x86/mm'
Depends on the simplifications from commit 1d7e707af446 ("Revert "x86/module: prepare module loading for ROX allocations of text"")
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Diffstat (limited to 'include/linux/execmem.h')
| -rw-r--r-- | include/linux/execmem.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/include/linux/execmem.h b/include/linux/execmem.h index 64130ae19690..65655a5d1be2 100644 --- a/include/linux/execmem.h +++ b/include/linux/execmem.h @@ -65,6 +65,37 @@ enum execmem_range_flags { * Architectures that use EXECMEM_ROX_CACHE must implement this. */ void execmem_fill_trapping_insns(void *ptr, size_t size, bool writable); + +/** + * execmem_make_temp_rw - temporarily remap region with read-write + * permissions + * @ptr: address of the region to remap + * @size: size of the region to remap + * + * Remaps a part of the cached large page in the ROX cache in the range + * [@ptr, @ptr + @size) as writable and not executable. The caller must + * have exclusive ownership of this range and ensure nothing will try to + * execute code in this range. + * + * Return: 0 on success or negative error code on failure. + */ +int execmem_make_temp_rw(void *ptr, size_t size); + +/** + * execmem_restore_rox - restore read-only-execute permissions + * @ptr: address of the region to remap + * @size: size of the region to remap + * + * Restores read-only-execute permissions on a range [@ptr, @ptr + @size) + * after it was temporarily remapped as writable. Relies on architecture + * implementation of set_memory_rox() to restore mapping using large pages. + * + * Return: 0 on success or negative error code on failure. + */ +int execmem_restore_rox(void *ptr, size_t size); +#else +static inline int execmem_make_temp_rw(void *ptr, size_t size) { return 0; } +static inline int execmem_restore_rox(void *ptr, size_t size) { return 0; } #endif /** |
