Patch "libbpf: Skip forward declaration when counting duplicated type names" has been added to the 5.15-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: Skip forward declaration when counting duplicated type names

to the 5.15-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-skip-forward-declaration-when-counting-duplic.patch
and it can be found in the queue-5.15 subdirectory.

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



commit cfa8214a3cafee52106b27b7a943fd0b49b6fc14
Author: Xu Kuohai <xukuohai@xxxxxxxxxx>
Date:   Tue Mar 1 00:32:49 2022 -0500

    libbpf: Skip forward declaration when counting duplicated type names
    
    [ Upstream commit 4226961b0019b2e1612029e8950a9e911affc995 ]
    
    Currently if a declaration appears in the BTF before the definition, the
    definition is dumped as a conflicting name, e.g.:
    
        $ bpftool btf dump file vmlinux format raw | grep "'unix_sock'"
        [81287] FWD 'unix_sock' fwd_kind=struct
        [89336] STRUCT 'unix_sock' size=1024 vlen=14
    
        $ bpftool btf dump file vmlinux format c | grep "struct unix_sock"
        struct unix_sock;
        struct unix_sock___2 {      <--- conflict, the "___2" is unexpected
                        struct unix_sock___2 *unix_sk;
    
    This causes a compilation error if the dump output is used as a header file.
    
    Fix it by skipping declaration when counting duplicated type names.
    
    Fixes: 351131b51c7a ("libbpf: add btf_dump API for BTF-to-C conversion")
    Signed-off-by: Xu Kuohai <xukuohai@xxxxxxxxxx>
    Signed-off-by: Daniel Borkmann <daniel@xxxxxxxxxxxxx>
    Acked-by: Song Liu <songliubraving@xxxxxx>
    Link: https://lore.kernel.org/bpf/20220301053250.1464204-2-xukuohai@xxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/lib/bpf/btf_dump.c b/tools/lib/bpf/btf_dump.c
index 463447a071d6..841cc68e3f42 100644
--- a/tools/lib/bpf/btf_dump.c
+++ b/tools/lib/bpf/btf_dump.c
@@ -1481,6 +1481,11 @@ static const char *btf_dump_resolve_name(struct btf_dump *d, __u32 id,
 	if (s->name_resolved)
 		return *cached_name ? *cached_name : orig_name;
 
+	if (btf_is_fwd(t) || (btf_is_enum(t) && btf_vlen(t) == 0)) {
+		s->name_resolved = 1;
+		return orig_name;
+	}
+
 	dup_cnt = btf_dump_name_dups(d, name_map, orig_name);
 	if (dup_cnt > 1) {
 		const size_t max_len = 256;



[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