Patch "bpftool: Only set obj->skeleton on complete success" has been added to the 5.17-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

    bpftool: Only set obj->skeleton on complete success

to the 5.17-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:
     bpftool-only-set-obj-skeleton-on-complete-success.patch
and it can be found in the queue-5.17 subdirectory.

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



commit 9e00c57fe3afa24541b53defb2e65d7b5d838865
Author: Wei Fu <fuweid89@xxxxxxxxx>
Date:   Sat Jan 8 16:40:08 2022 +0800

    bpftool: Only set obj->skeleton on complete success
    
    [ Upstream commit 0991f6a38f576aa9a5e34713e23c998a3310d4d0 ]
    
    After `bpftool gen skeleton`, the ${bpf_app}.skel.h will provide that
    ${bpf_app_name}__open helper to load bpf. If there is some error
    like ENOMEM, the ${bpf_app_name}__open will rollback(free) the allocated
    object, including `bpf_object_skeleton`.
    
    Since the ${bpf_app_name}__create_skeleton set the obj->skeleton first
    and not rollback it when error, it will cause double-free in
    ${bpf_app_name}__destory at ${bpf_app_name}__open. Therefore, we should
    set the obj->skeleton before return 0;
    
    Fixes: 5dc7a8b21144 ("bpftool, selftests/bpf: Embed object file inside skeleton")
    Signed-off-by: Wei Fu <fuweid89@xxxxxxxxx>
    Signed-off-by: Andrii Nakryiko <andrii@xxxxxxxxxx>
    Link: https://lore.kernel.org/bpf/20220108084008.1053111-1-fuweid89@xxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
index b4695df2ea3d..a7387c265e3c 100644
--- a/tools/bpf/bpftool/gen.c
+++ b/tools/bpf/bpftool/gen.c
@@ -927,7 +927,6 @@ static int do_skeleton(int argc, char **argv)
 			s = (struct bpf_object_skeleton *)calloc(1, sizeof(*s));\n\
 			if (!s)						    \n\
 				goto err;				    \n\
-			obj->skeleton = s;				    \n\
 									    \n\
 			s->sz = sizeof(*s);				    \n\
 			s->name = \"%1$s\";				    \n\
@@ -1000,6 +999,7 @@ static int do_skeleton(int argc, char **argv)
 									    \n\
 			s->data = (void *)%2$s__elf_bytes(&s->data_sz);	    \n\
 									    \n\
+			obj->skeleton = s;				    \n\
 			return 0;					    \n\
 		err:							    \n\
 			bpf_object__destroy_skeleton(s);		    \n\



[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