Patch "bpftool: Un-const bpf_func_info to fix it for llvm 17 and newer" has been added to the 6.1-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: Un-const bpf_func_info to fix it for llvm 17 and newer

to the 6.1-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-un-const-bpf_func_info-to-fix-it-for-llvm-17.patch
and it can be found in the queue-6.1 subdirectory.

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



commit b2c009d346f476b4c95bcaf52bdc1f3111c53f14
Author: Ivan Babrou <ivan@xxxxxxxxxxxxxx>
Date:   Mon May 20 15:51:49 2024 -0700

    bpftool: Un-const bpf_func_info to fix it for llvm 17 and newer
    
    [ Upstream commit f4aba3471cfb9ccf69b476463f19b4c50fef6b14 ]
    
    LLVM 17 started treating const structs as constants:
    
    * https://github.com/llvm/llvm-project/commit/0b2d5b967d98
    
    Combined with pointer laundering via ptr_to_u64, which takes a const ptr,
    but in reality treats the underlying memory as mutable, this makes clang
    always pass zero to btf__type_by_id, which breaks full name resolution.
    
    Disassembly before (LLVM 16) and after (LLVM 17):
    
        -    8b 75 cc                 mov    -0x34(%rbp),%esi
        -    e8 47 8d 02 00           call   3f5b0 <btf__type_by_id>
        +    31 f6                    xor    %esi,%esi
        +    e8 a9 8c 02 00           call   3f510 <btf__type_by_id>
    
    It's a bigger project to fix this properly (and a question whether LLVM
    itself should detect this), but for right now let's just fix bpftool.
    
    For more information, see this thread in bpf mailing list:
    
    * https://lore.kernel.org/bpf/CABWYdi0ymezpYsQsPv7qzpx2fWuTkoD1-wG1eT-9x-TSREFrQg@xxxxxxxxxxxxxx/T/
    
    Fixes: b662000aff84 ("bpftool: Adding support for BTF program names")
    Signed-off-by: Ivan Babrou <ivan@xxxxxxxxxxxxxx>
    Signed-off-by: Andrii Nakryiko <andrii@xxxxxxxxxx>
    Acked-by: Nick Desaulniers <ndesaulniers@xxxxxxxxxx>
    Acked-by: Yonghong Song <yonghong.song@xxxxxxxxx>
    Link: https://lore.kernel.org/bpf/20240520225149.5517-1-ivan@xxxxxxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/bpf/bpftool/common.c b/tools/bpf/bpftool/common.c
index e7a11cff7245a..db02b000fbebd 100644
--- a/tools/bpf/bpftool/common.c
+++ b/tools/bpf/bpftool/common.c
@@ -333,7 +333,7 @@ void get_prog_full_name(const struct bpf_prog_info *prog_info, int prog_fd,
 {
 	const char *prog_name = prog_info->name;
 	const struct btf_type *func_type;
-	const struct bpf_func_info finfo = {};
+	struct bpf_func_info finfo = {};
 	struct bpf_prog_info info = {};
 	__u32 info_len = sizeof(info);
 	struct btf *prog_btf = NULL;




[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