public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Friedrich Vock <friedrich.vock@gmx.de>
To: bpf@vger.kernel.org
Cc: Jiri Olsa <jolsa@kernel.org>
Subject: [PATCH] bpf: Fix potential integer overflow in resolve_btfids
Date: Tue, 14 May 2024 09:09:31 +0200	[thread overview]
Message-ID: <20240514070931.199694-1-friedrich.vock@gmx.de> (raw)

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.

Signed-off-by: Friedrich Vock <friedrich.vock@gmx.de>

Fixes: fbbb68de80a4 ("bpf: Add resolve_btfids tool to resolve BTF IDs in ELF object")
Cc: Jiri Olsa <jolsa@kernel.org>
---
 tools/bpf/resolve_btfids/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/bpf/resolve_btfids/main.c b/tools/bpf/resolve_btfids/main.c
index d9520cb826b31..af393c7dee1f1 100644
--- a/tools/bpf/resolve_btfids/main.c
+++ b/tools/bpf/resolve_btfids/main.c
@@ -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)   ||
--
2.45.0


             reply	other threads:[~2024-05-14  7:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-14  7:09 Friedrich Vock [this message]
2024-05-24 15:20 ` [PATCH] bpf: Fix potential integer overflow in resolve_btfids patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240514070931.199694-1-friedrich.vock@gmx.de \
    --to=friedrich.vock@gmx.de \
    --cc=bpf@vger.kernel.org \
    --cc=jolsa@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox