On Mon, Sep 1, 2025 at 6:34 AM Puranjay Mohan <puranjay@xxxxxxxxxx> wrote: > > Alexei Starovoitov <alexei.starovoitov@xxxxxxxxx> writes: > > > On Fri, Aug 29, 2025 at 3:30 AM Xu Kuohai <xukuohai@xxxxxxxxxxxxxxx> wrote: > >> > >> > + > >> > +void bpf_prog_report_arena_violation(bool write, unsigned long addr) > >> > +{ > >> > + struct bpf_stream_stage ss; > >> > + struct bpf_prog *prog; > >> > + u64 user_vm_start; > >> > + > >> > + prog = bpf_prog_find_from_stack(); > >> > >> bpf_prog_find_from_stack depends on arch_bpf_stack_walk, which isn't available > >> on all archs. How about switching to bpf_prog_ksym_find with the fault pc? > > > > Out of archs that support bpf arena only riscv doesn't > > support arch_bpf_stack_walk(), which is probably fixable. > > But I agree that direct bpf_prog_ksym_find() is cleaner here. > > We need to make sure it works for subprogs, since streams[2] are > > valid only for main prog. > > I think we can add: > > struct bpf_prog_aux { > > ... > > struct bpf_prog_aux *main_prog; > > }; > > init it during jit_subprogs() and use it for stream access. > > We can also remove skipping of subprogs in find_from_stack_cb() then. > > > > Kumar, wdyt? > > So, IIUC, after adding struct bpf_prog_aux *main_prog_aux in struct > bpf_prog_aux, > > We can do in bpf_prog_alloc_no_stats(): > fp->aux->main_prog_aux = aux; > > and in jit_subprogs(): > func[i]->aux->main_prog_aux = prog->aux; > > and then all users of bpf_stream_get() can do > bpf_stream_get(stream_id, prog->aux->main_prog_aux); > > with above we can allow find_from_stack_cb() to return subprogs. > and bpf_prog_ksym_find() can be used in > bpf_prog_report_arena_violation() without any other changes. Yes. That's exactly the proposal.