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]

 



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.

Thanks,
Puranjay





[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