]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
bpf: Fix potential integer overflow in resolve_btfids
authorFriedrich Vock <friedrich.vock@gmx.de>
Tue, 14 May 2024 07:09:31 +0000 (09:09 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 16 Jun 2024 11:39:50 +0000 (13:39 +0200)
commite5138f43c97de3330f4eb58cbc21e9b226e2605e
tree1fb1aa02dcfa6fb06eab09420ba31ef1fe8d6091
parent9d75fab2c14a25553a1664586ed122c316bd1878
bpf: Fix potential integer overflow in resolve_btfids

[ Upstream commit 44382b3ed6b2787710c8ade06c0e97f5970a47c8 ]

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: fbbb68de80a4 ("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
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/bpf/resolve_btfids/main.c