Skip to content

Commit fc85047

Browse files
xhackerustcpalmer-dabbelt
authored andcommitted
riscv: bpf: Avoid breaking W^X
We allocate Non-executable pages, then call bpf_jit_binary_lock_ro() to enable executable permission after mapping them read-only. This is to prepare for STRICT_MODULE_RWX in following patch. Signed-off-by: Jisheng Zhang <[email protected]> Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 1d27d85 commit fc85047

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/riscv/net/bpf_jit_core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
152152
bpf_flush_icache(jit_data->header, ctx->insns + ctx->ninsns);
153153

154154
if (!prog->is_func || extra_pass) {
155+
bpf_jit_binary_lock_ro(jit_data->header);
155156
out_offset:
156157
kfree(ctx->offset);
157158
kfree(jit_data);
@@ -169,7 +170,7 @@ void *bpf_jit_alloc_exec(unsigned long size)
169170
{
170171
return __vmalloc_node_range(size, PAGE_SIZE, BPF_JIT_REGION_START,
171172
BPF_JIT_REGION_END, GFP_KERNEL,
172-
PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE,
173+
PAGE_KERNEL, 0, NUMA_NO_NODE,
173174
__builtin_return_address(0));
174175
}
175176

0 commit comments

Comments
 (0)