Re: [PATCH bpf-next v4 2/3] bpf: Report arena faults to BPF stderr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?

In a bigger follow up maybe we can split bpf_prog_aux into two
structures for main prog and for subprogs, since we copy
a bunch of pointers from main into subprogs.
With 'main_prog' pointer all these pointers (like linfo, func_info,
kfunc_tab, arena, btf) can stay in 'struct bpf_main_prog_aux',
so 'struct bpf_subprog_aux' can be smaller.





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux