Patch "riscv: bpf: Avoid breaking W^X" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    riscv: bpf: Avoid breaking W^X

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     riscv-bpf-avoid-breaking-w-x.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 4050c9f9f0d0ac97014d29d95259e3be1ebede8a
Author: Jisheng Zhang <jszhang@xxxxxxxxxx>
Date:   Tue Mar 30 02:25:21 2021 +0800

    riscv: bpf: Avoid breaking W^X
    
    [ Upstream commit fc8504765ec5e812135b8ccafca7101069a0c6d8 ]
    
    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 <jszhang@xxxxxxxxxx>
    Signed-off-by: Palmer Dabbelt <palmerdabbelt@xxxxxxxxxx>
    Stable-dep-of: c56fb2aab235 ("riscv, bpf: Fix inconsistent JIT image generation")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/riscv/net/bpf_jit_core.c b/arch/riscv/net/bpf_jit_core.c
index e295c9eed9e93..5d247198c30d3 100644
--- a/arch/riscv/net/bpf_jit_core.c
+++ b/arch/riscv/net/bpf_jit_core.c
@@ -153,6 +153,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
 	bpf_flush_icache(jit_data->header, ctx->insns + ctx->ninsns);
 
 	if (!prog->is_func || extra_pass) {
+		bpf_jit_binary_lock_ro(jit_data->header);
 out_offset:
 		kfree(ctx->offset);
 		kfree(jit_data);
@@ -170,7 +171,7 @@ void *bpf_jit_alloc_exec(unsigned long size)
 {
 	return __vmalloc_node_range(size, PAGE_SIZE, BPF_JIT_REGION_START,
 				    BPF_JIT_REGION_END, GFP_KERNEL,
-				    PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE,
+				    PAGE_KERNEL, 0, NUMA_NO_NODE,
 				    __builtin_return_address(0));
 }
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux