Skip to content

Commit 8352fdf

Browse files
radimkrcmargregkh
authored andcommitted
riscv, bpf: use lw when reading int cpu in bpf_get_smp_processor_id
commit 8a16586 upstream. emit_ld is wrong, because thread_info.cpu is 32-bit, not xlen-bit wide. The struct currently has a hole after cpu, so little endian accesses seemed fine. Fixes: 2ddec2c ("riscv, bpf: inline bpf_get_smp_processor_id()") Cc: stable@vger.kernel.org Signed-off-by: Radim Krčmář <rkrcmar@ventanamicro.com> Reviewed-by: Pu Lehui <pulehui@huawei.com> Link: https://lore.kernel.org/r/20250812090256.757273-4-rkrcmar@ventanamicro.com Signed-off-by: Paul Walmsley <pjw@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1a1e84c commit 8352fdf

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

arch/riscv/net/bpf_jit_comp64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1557,7 +1557,7 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, struct rv_jit_context *ctx,
15571557
*/
15581558
if (insn->src_reg == 0 && insn->imm == BPF_FUNC_get_smp_processor_id) {
15591559
/* Load current CPU number in R0 */
1560-
emit_ld(bpf_to_rv_reg(BPF_REG_0, ctx), offsetof(struct thread_info, cpu),
1560+
emit_lw(bpf_to_rv_reg(BPF_REG_0, ctx), offsetof(struct thread_info, cpu),
15611561
RV_REG_TP, ctx);
15621562
break;
15631563
}

0 commit comments

Comments
 (0)