Re: [PATCH bpf-next 1/2] bpf: Fix memleak due to fentry attach failure

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

 



On Wed, May 10, 2023 at 2:24 PM Song Liu <song@xxxxxxxxxx> wrote:
>
> On Tue, May 9, 2023 at 7:39 PM Yafang Shao <laoar.shao@xxxxxxxxx> wrote:
> >
> > On Wed, May 10, 2023 at 1:41 AM Song Liu <song@xxxxxxxxxx> wrote:
> [...]
> > > > +static void bpf_tramp_image_free(struct bpf_tramp_image *im)
> > > > +{
> > > > +       bpf_image_ksym_del(&im->ksym);
> > > > +       bpf_jit_free_exec(im->image);
> > > > +       bpf_jit_uncharge_modmem(PAGE_SIZE);
> > > > +       percpu_ref_exit(&im->pcref);
> > > > +       kfree(im);
> > > > +}
> > >
> > > Can we share some of this function with __bpf_tramp_image_put_deferred?
> > >
> >
> > It seems we can introduce a generic helper as follows,
> >   static void __bpf_tramp_image_free(struct bpf_tramp_image *im)
> >   {
> >       bpf_image_ksym_del(&im->ksym);
> >       bpf_jit_free_exec(im->image);
> >       bpf_jit_uncharge_modmem(PAGE_SIZE);
> >       percpu_ref_exit(&im->pcref);
> >   }
> >
> > And then use it in both bpf_tramp_image_free() and
> > __bpf_tramp_image_put_deferred().
> > WDYT?
>
> How about we also use kfree_rcu() in bpf_tramp_image_free()?
>

Looks good. I will change it.

-- 
Regards
Yafang





[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