libbpf: fix another __u64 cast in printf
Subsystems (4)
PATCH 1/2 libbpf: fix another __u64 cast in printf
Another issue of __u64 needing either %lu or %llu, depending on the architecture. Fix with cast to unsigned long long.
Fixes 7e06aad52929 ("libbpf: Add multi-prog section support for struct_ops")
Signed-off-by Andrii Nakryiko <[email protected]>
--- tools/lib/bpf/libbpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/libbpf.c +1 -1
@@ -8224,7 +8224,7 @@ static int bpf_object__collect_st_ops_relos(struct bpf_object *obj, }if (sym.st_value %BPF_INSN_SZ ) {pr_warn ("struct_ops reloc %s: invalid target program offset %llu\n" , - map->name, (__u64 )sym.st_value); + map->name, (unsigned long long )sym.st_value);return -LIBBPF_ERRNO__FORMAT ; } insn_idx = sym.st_value /BPF_INSN_SZ ;
Signature · 1 line
2.24.1
PATCH 2/2 libbpf: fix potential multiplication overflow
Detected by LGTM static analyze in Github repo, fix potential multiplication overflow before result is casted to size_t.
Fixes 8505e8709b5e ("libbpf: Implement generalized .BTF.ext func/line info adjustment")
Signed-off-by Andrii Nakryiko <[email protected]>
--- tools/lib/bpf/libbpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/libbpf.c +1 -1
@@ -5802,7 +5802,7 @@ static int adjust_prog_btf_ext_info(const struct bpf_object *obj,/* append func/line info of a given (sub-)program to the main * program func/line info */ - old_sz = (*prog_rec_cnt) * ext_info->rec_size; + old_sz = (size_t )(*prog_rec_cnt) * ext_info->rec_size; new_sz = old_sz + (copy_end - copy_start); new_prog_info =realloc (*prog_info, new_sz);if (!new_prog_info)
Signature · 1 line
2.24.1
Quoted 5 lines · Andrii Nakryiko
Another issue of
__u64needing either %lu or %llu, depending on the architecture. Fix with cast tounsigned long long.Fixes 7e06aad52929 ("libbpf: Add multi-prog section support for struct_ops")Signed-off-by Andrii Nakryiko <[email protected]>
Applied, thanks!