arm64: extend execmem_info for generated code allocations
authorMike Rapoport (IBM) <rppt@kernel.org>
Sun, 5 May 2024 16:06:22 +0000 (19:06 +0300)
committerLuis Chamberlain <mcgrof@kernel.org>
Tue, 14 May 2024 07:31:43 +0000 (00:31 -0700)
The memory allocations for kprobes and BPF on arm64 can be placed
anywhere in vmalloc address space and currently this is implemented with
overrides of alloc_insn_page() and bpf_jit_alloc_exec() in arm64.

Define EXECMEM_KPROBES and EXECMEM_BPF ranges in arm64::execmem_info and
drop overrides of alloc_insn_page() and bpf_jit_alloc_exec().

Signed-off-by: Mike Rapoport (IBM) <rppt@kernel.org>
Acked-by: Will Deacon <will@kernel.org>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
arch/arm64/kernel/module.c
arch/arm64/kernel/probes/kprobes.c
arch/arm64/net/bpf_jit_comp.c

index b7a7a23f9f8f4e95d96a1543d4571d8fdca614cf..a52240ea084bb57f89bc7fa348d131e321bbd96f 100644 (file)
@@ -146,6 +146,18 @@ struct execmem_info __init *execmem_arch_setup(void)
                                .fallback_start = fallback_start,
                                .fallback_end   = fallback_end,
                        },
+                       [EXECMEM_KPROBES] = {
+                               .start  = VMALLOC_START,
+                               .end    = VMALLOC_END,
+                               .pgprot = PAGE_KERNEL_ROX,
+                               .alignment = 1,
+                       },
+                       [EXECMEM_BPF] = {
+                               .start  = VMALLOC_START,
+                               .end    = VMALLOC_END,
+                               .pgprot = PAGE_KERNEL,
+                               .alignment = 1,
+                       },
                },
        };
 
index 327855a11df2f74628f21621ce5e6f31ba9651b9..4268678d0e86cc6cb3c25f13c2ab087a41876f76 100644 (file)
@@ -129,13 +129,6 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
        return 0;
 }
 
-void *alloc_insn_page(void)
-{
-       return __vmalloc_node_range(PAGE_SIZE, 1, VMALLOC_START, VMALLOC_END,
-                       GFP_KERNEL, PAGE_KERNEL_ROX, VM_FLUSH_RESET_PERMS,
-                       NUMA_NO_NODE, __builtin_return_address(0));
-}
-
 /* arm kprobe: install breakpoint in text */
 void __kprobes arch_arm_kprobe(struct kprobe *p)
 {
index 13eac43c632dfe793912ba310f7449d59e3bd9ed..074b1d156223f85763e9e7bb969faffcc77b0cbe 100644 (file)
@@ -1793,17 +1793,6 @@ u64 bpf_jit_alloc_exec_limit(void)
        return VMALLOC_END - VMALLOC_START;
 }
 
-void *bpf_jit_alloc_exec(unsigned long size)
-{
-       /* Memory is intended to be executable, reset the pointer tag. */
-       return kasan_reset_tag(vmalloc(size));
-}
-
-void bpf_jit_free_exec(void *addr)
-{
-       return vfree(addr);
-}
-
 /* Indicate the JIT backend supports mixing bpf2bpf and tailcalls. */
 bool bpf_jit_supports_subprog_tailcalls(void)
 {