Re: [PATCH bpf-next 6/8] bpf: Add arch_bpf_trampoline_size()

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

 



On Wed, Sep 20, 2023 at 5:46 PM Pu Lehui <pulehui@xxxxxxxxxx> wrote:
>
[...]
> > +int arch_bpf_trampoline_size(const struct btf_func_model *m, u32 flags,
> > +                          struct bpf_tramp_links *tlinks, void *func_addr)
> > +{
> > +     struct bpf_tramp_image im;
> > +     struct rv_jit_context ctx;
> > +
> > +     ctx.ninsns = 0;
> > +     ctx.insns = NULL;
> > +     ctx.ro_insns = NULL;
> > +     ret = __arch_prepare_bpf_trampoline(&im, m, tlinks, func_addr, flags, &ctx);
> > +
> > +     return ret < 0 ? ret : ninsns_rvoff(ctx->ninsns);
> > +}
> > +
> >   int arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *image,
> >                               void *image_end, const struct btf_func_model *m,
> >                               u32 flags, struct bpf_tramp_links *tlinks,
> > @@ -1032,14 +1046,8 @@ int arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *image,
> >       int ret;
> >       struct rv_jit_context ctx;
> >
> > -     ctx.ninsns = 0;
> > -     ctx.insns = NULL;
> > -     ctx.ro_insns = NULL;
> > -     ret = __arch_prepare_bpf_trampoline(im, m, tlinks, func_addr, flags, &ctx);
> > -     if (ret < 0)
> > -             return ret;
> > -
> > -     if (ninsns_rvoff(ret) > (long)image_end - (long)image)
> > +     ret = arch_bpf_trampoline_size(im, m, flags, tlinks, func_addr);
>
> Hi Song, there is missing check for negative return values.

Thanks! I will fix it in the next version.

Song

> > +     if (ret > (long)image_end - (long)image)
> >               return -EFBIG;
> >
> >       ctx.ninsns = 0;
> > diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
> > index e6a643f63ebf..8fab4795b497 100644
> > --- a/arch/s390/net/bpf_jit_comp.c
> > +++ b/arch/s390/net/bpf_jit_comp.c
> > @@ -2483,6 +2483,21 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im,
> >       return 0;
> >   }
[...]





[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