Skip to content

Commit

Permalink
bpf: Fix potential integer overflow in resolve_btfids
Browse files Browse the repository at this point in the history
err is a 32-bit integer, but elf_update returns an off_t, which is 64-bit
at least on 64-bit platforms. If symbols_patch is called on a binary between
2-4GB in size, the result will be negative when cast to a 32-bit integer,
which the code assumes means an error occurred. This can wrongly trigger
build failures when building very large kernel images.

Fixes: fbbb68d ("bpf: Add resolve_btfids tool to resolve BTF IDs in ELF object")
Signed-off-by: Friedrich Vock <friedrich.vock@gmx.de>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20240514070931.199694-1-friedrich.vock@gmx.de
  • Loading branch information
pixelcluster authored and borkmann committed May 24, 2024
1 parent 8d00547 commit 44382b3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/bpf/resolve_btfids/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ static int sets_patch(struct object *obj)

static int symbols_patch(struct object *obj)
{
int err;
off_t err;

if (__symbols_patch(obj, &obj->structs) ||
__symbols_patch(obj, &obj->unions) ||
Expand Down

0 comments on commit 44382b3

Please sign in to comment.