diff mbox series

libbpf: Fix signedness bug in btf_dump_array_data()

Message ID 20220208071552.GB10495@kili (mailing list archive)
State Accepted
Commit 4172843ed4a38f97084032f74f07b2037b5da3a6
Delegated to: BPF
Headers show
Series libbpf: Fix signedness bug in btf_dump_array_data() | expand

Checks

Context Check Description
bpf/vmtest-bpf-next-PR fail PR summary
bpf/vmtest-bpf-next fail VM_Test
netdev/tree_selection success Not a local patch

Commit Message

Dan Carpenter Feb. 8, 2022, 7:15 a.m. UTC
The btf__resolve_size() function returns negative error codes so
"elem_size" must be signed for the error handling to work.

Fixes: 920d16af9b42 ("libbpf: BTF dumper support for typed data")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 tools/lib/bpf/btf_dump.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Yonghong Song Feb. 8, 2022, 4:08 p.m. UTC | #1
On 2/7/22 11:15 PM, Dan Carpenter wrote:
> The btf__resolve_size() function returns negative error codes so
> "elem_size" must be signed for the error handling to work.
> 
> Fixes: 920d16af9b42 ("libbpf: BTF dumper support for typed data")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Acked-by: Yonghong Song <yhs@fb.com>
patchwork-bot+netdevbpf@kernel.org Feb. 8, 2022, 9:40 p.m. UTC | #2
Hello:

This patch was applied to bpf/bpf-next.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:

On Tue, 8 Feb 2022 10:15:52 +0300 you wrote:
> The btf__resolve_size() function returns negative error codes so
> "elem_size" must be signed for the error handling to work.
> 
> Fixes: 920d16af9b42 ("libbpf: BTF dumper support for typed data")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  tools/lib/bpf/btf_dump.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Here is the summary with links:
  - libbpf: Fix signedness bug in btf_dump_array_data()
    https://git.kernel.org/bpf/bpf-next/c/4172843ed4a3

You are awesome, thank you!
diff mbox series

Patch

diff --git a/tools/lib/bpf/btf_dump.c b/tools/lib/bpf/btf_dump.c
index b9a3260c83cb..55aed9e398c3 100644
--- a/tools/lib/bpf/btf_dump.c
+++ b/tools/lib/bpf/btf_dump.c
@@ -1861,14 +1861,15 @@  static int btf_dump_array_data(struct btf_dump *d,
 {
 	const struct btf_array *array = btf_array(t);
 	const struct btf_type *elem_type;
-	__u32 i, elem_size = 0, elem_type_id;
+	__u32 i, elem_type_id;
+	__s64 elem_size;
 	bool is_array_member;
 
 	elem_type_id = array->type;
 	elem_type = skip_mods_and_typedefs(d->btf, elem_type_id, NULL);
 	elem_size = btf__resolve_size(d->btf, elem_type_id);
 	if (elem_size <= 0) {
-		pr_warn("unexpected elem size %d for array type [%u]\n", elem_size, id);
+		pr_warn("unexpected elem size %lld for array type [%u]\n", elem_size, id);
 		return -EINVAL;
 	}