Re: [PATCH v3] riscv: probes: reject kprobes inside LR/SC sequences

Nam Cao <[email protected]>
Newsgroups org.infradead.lists.linux-riscv
Message-ID <[email protected]>
Xiaofeng Yuan <[email protected]> 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

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.