[PATCH v3] riscv: probes: reject kprobes inside LR/SC sequences
Nam Cao
namcao at linutronix.de
Wed Aug 26 06:12:02 PDT 2026
Xiaofeng Yuan <yuanxiaofeng at eswincomputing.com> writes:
> + while (tmp > scan_end && count < MAX_ATOMIC_CONTEXT_INSN) {
> + u16 halfword = get_unaligned((u16 *)(tmp - 2));
> + unsigned int len = (halfword & 0x3) == 0x3 ? 4 : 2;
> +
> + if (tmp - len < scan_end)
> + break;
> +
> + if (len == 4) {
> + u32 insn = get_unaligned((u32 *)(tmp - 4));
> +
> + if (riscv_insn_is_lr(insn))
> + in_atomic = true;
> + else if (riscv_insn_is_sc(insn))
> + in_atomic = false;
> + }
> +
> + tmp -= len;
> + count++;
> + }
This does not look right. If we have
lr
another instruction
sc
probed instruction
Then riscv_probe_insn_in_atomic() return true, which is clearly wrong.
Have you even tested this patch?
Nam
More information about the linux-riscv
mailing list