Re: [PATCH bpf] bpf: Cleanup ftrace hash in bpf_trampoline_put

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

 



On Tue, Aug 2, 2022 at 6:57 AM Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
>
> We need to release possible hash from trampoline fops object
> before removing it, otherwise we leak it.
>
> Fixes: 00963a2e75a8 ("bpf: Support bpf_trampoline on functions with IPMODIFY (e.g. livepatch)")
> Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>

Great catch! Thanks!

Acked-by: Song Liu <song@xxxxxxxxxx>

> ---
>  kernel/bpf/trampoline.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/trampoline.c b/kernel/bpf/trampoline.c
> index 0f532e6a717f..ff87e38af8a7 100644
> --- a/kernel/bpf/trampoline.c
> +++ b/kernel/bpf/trampoline.c
> @@ -841,7 +841,10 @@ void bpf_trampoline_put(struct bpf_trampoline *tr)
>          * multiple rcu callbacks.
>          */
>         hlist_del(&tr->hlist);
> -       kfree(tr->fops);
> +       if (tr->fops) {
> +               ftrace_free_filter(tr->fops);
> +               kfree(tr->fops);
> +       }
>         kfree(tr);
>  out:
>         mutex_unlock(&trampoline_mutex);
> --
> 2.37.1
>



[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