Patch "libbpf: Free btf_vmlinux when closing bpf_object" has been added to the 5.10-stable tree

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

 



This is a note to let you know that I've just added the patch titled

    libbpf: Free btf_vmlinux when closing bpf_object

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     libbpf-free-btf_vmlinux-when-closing-bpf_object.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 7eafa0453fad740d53915d98678684fd8d80890a
Author: Hao Luo <haoluo@xxxxxxxxxx>
Date:   Tue Aug 22 12:38:40 2023 -0700

    libbpf: Free btf_vmlinux when closing bpf_object
    
    [ Upstream commit 29d67fdebc42af6466d1909c60fdd1ef4f3e5240 ]
    
    I hit a memory leak when testing bpf_program__set_attach_target().
    Basically, set_attach_target() may allocate btf_vmlinux, for example,
    when setting attach target for bpf_iter programs. But btf_vmlinux
    is freed only in bpf_object_load(), which means if we only open
    bpf object but not load it, setting attach target may leak
    btf_vmlinux.
    
    So let's free btf_vmlinux in bpf_object__close() anyway.
    
    Signed-off-by: Hao Luo <haoluo@xxxxxxxxxx>
    Signed-off-by: Andrii Nakryiko <andrii@xxxxxxxxxx>
    Link: https://lore.kernel.org/bpf/20230822193840.1509809-1-haoluo@xxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 015ed8253f739..44646c5286fbe 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -7962,6 +7962,7 @@ void bpf_object__close(struct bpf_object *obj)
 	bpf_object__elf_finish(obj);
 	bpf_object__unload(obj);
 	btf__free(obj->btf);
+	btf__free(obj->btf_vmlinux);
 	btf_ext__free(obj->btf_ext);
 
 	for (i = 0; i < obj->nr_maps; i++)



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux