Skip to content

Commit eb71f5c

Browse files
chenhengqichenhuacai
authored andcommitted
LoongArch: BPF: Zero-extend bpf_tail_call() index
The bpf_tail_call() index should be treated as a u32 value. Let's zero-extend it to avoid calling wrong BPF progs. See similar fixes for x86 [1]) and arm64 ([2]) for more details. [1]: torvalds@90caccd [2]: torvalds@16338a9 Cc: stable@vger.kernel.org Fixes: 5dc6155 ("LoongArch: Add BPF JIT support") Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
1 parent 3f5a238 commit eb71f5c

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

arch/loongarch/net/bpf_jit.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ static int emit_bpf_tail_call(struct jit_ctx *ctx, int insn)
280280
* goto out;
281281
*/
282282
tc_ninsn = insn ? ctx->offset[insn+1] - ctx->offset[insn] : ctx->offset[0];
283+
emit_zext_32(ctx, a2, true);
284+
283285
off = offsetof(struct bpf_array, map.max_entries);
284286
emit_insn(ctx, ldwu, t1, a1, off);
285287
/* bgeu $a2, $t1, jmp_offset */

0 commit comments

Comments
 (0)