aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/bpf_doc.py
diff options
context:
space:
mode:
authorDan Carpenter <[email protected]>2022-07-19 09:49:34 +0000
committerDaniel Borkmann <[email protected]>2022-07-21 12:24:18 +0000
commitc6018fc6e7b6fcc4ac5430870c2e8b4ca556621a (patch)
tree597b404ce47c25c8bfa1250d03ca63e3128c44ce /scripts/bpf_doc.py
parentbpf: Fix bpf_trampoline_{,un}link_cgroup_shim ifdef guards (diff)
downloadkernel-c6018fc6e7b6fcc4ac5430870c2e8b4ca556621a.tar.gz
kernel-c6018fc6e7b6fcc4ac5430870c2e8b4ca556621a.zip
libbpf: Fix sign expansion bug in btf_dump_get_enum_value()
The code here is supposed to take a signed int and store it in a signed long long. Unfortunately, the way that the type promotion works with this conditional statement is that it takes a signed int, type promotes it to a __u32, and then stores that as a signed long long. The result is never negative. This is from static analysis, but I made a little test program just to test it before I sent the patch: #include <stdio.h> int main(void) { unsigned long long src = -1ULL; signed long long dst1, dst2; int is_signed = 1; dst1 = is_signed ? *(int *)&src : *(unsigned int *)0; dst2 = is_signed ? (signed long long)*(int *)&src : *(unsigned int *)0; printf("%lld\n", dst1); printf("%lld\n", dst2); return 0; } Fixes: d90ec262b35b ("libbpf: Add enum64 support for btf_dump") Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Martin KaFai Lau <[email protected]> Link: https://lore.kernel.org/bpf/YtZ+LpgPADm7BeEd@kili
Diffstat (limited to 'scripts/bpf_doc.py')
0 files changed, 0 insertions, 0 deletions