Re: [PATCH v3] bpf, riscv: fix extable handling for arena load_acquire

From: Kumar Kartikeya Dwivedi

Date: Tue Jul 21 2026 - 14:44:34 EST


On Tue Jul 21, 2026 at 8:17 PM CEST, Björn Töpel wrote:
> Feng Jiang <jiangfeng@xxxxxxxxxx> writes:
>
>> emit_atomic_ld_st() returns 1 to have build_body() skip the zext after
>> a sub-word load_acquire. The caller does "ret = ret ?:
>> add_exception_handler(...)", which skips add_exception_handler() on any
>> non-zero ret, so the extable entry is missing and a faulting
>> PROBE_ATOMIC load_acquire oopses.
>>
>> REG_DONT_CLEAR_MARKER leaves rd stale on fault, and the verifier still
>> thinks the load overwrote it, so a program can leak it through a map.
>>
>> Check ret >= 0 before calling add_exception_handler(), and pass rd for
>> LOAD_ACQ so the fault zeroes rd like a PROBE_MEM load. Return ret
>> unchanged for the zext skip.
>>
>> Fixes: fb7cefabae81 ("riscv, bpf: Add support arena atomics for RV64")
>> Signed-off-by: Feng Jiang <jiangfeng@xxxxxxxxxx>
>
> Thank you for spinning a new version!
>
> Reviewed-by: Björn Töpel <bjorn@xxxxxxxxxx>
> Acked-by: Björn Töpel <bjorn@xxxxxxxxxx>

There was an identical v4 resend. I applied the acks there and pushed.
Thanks.