public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@kernel.org>
To: stable@vger.kernel.org
Cc: Andrii Nakryiko <andrii@kernel.org>,
	bpf@vger.kernel.org, Daniel Borkmann <daniel@iogearbox.net>
Subject: [PATCH stable 5.15] lib/buildid: Fix build ID parsing logic
Date: Mon,  4 Nov 2024 18:52:53 +0100	[thread overview]
Message-ID: <20241104175256.2327164-2-jolsa@kernel.org> (raw)
In-Reply-To: <20241104175256.2327164-1-jolsa@kernel.org>

The parse_build_id_buf does not account Elf32_Nhdr header size
when getting the build id data pointer and returns wrong build
id data as result.

This is problem only stable trees that merged 8fa2b6817a95 fix,
the upstream build id code was refactored and returns proper
build id.

Acked-by: Andrii Nakryiko <andrii@kernel.org>
Fixes: 8fa2b6817a95 ("lib/buildid: harden build ID parsing logic")
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 lib/buildid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/buildid.c b/lib/buildid.c
index e41fb0ee405f..cc5da016b235 100644
--- a/lib/buildid.c
+++ b/lib/buildid.c
@@ -40,7 +40,7 @@ static int parse_build_id_buf(unsigned char *build_id,
 		    name_sz == note_name_sz &&
 		    memcmp(nhdr + 1, note_name, note_name_sz) == 0 &&
 		    desc_sz > 0 && desc_sz <= BUILD_ID_SIZE_MAX) {
-			data = note_start + note_off + ALIGN(note_name_sz, 4);
+			data = note_start + note_off + sizeof(Elf32_Nhdr) + ALIGN(note_name_sz, 4);
 			memcpy(build_id, data, desc_sz);
 			memset(build_id + desc_sz, 0, BUILD_ID_SIZE_MAX - desc_sz);
 			if (size)
-- 
2.47.0


  reply	other threads:[~2024-11-04 17:53 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-04 17:52 Fix build ID parsing logic in stable trees Jiri Olsa
2024-11-04 17:52 ` Jiri Olsa [this message]
2024-11-04 17:52 ` [PATCH stable 6.1 ] lib/buildid: Fix build ID parsing logic Jiri Olsa
2024-11-04 17:52 ` [PATCH stable 6.6 " Jiri Olsa
2024-11-04 17:52 ` [PATCH stable 6.11] " Jiri Olsa
2024-11-05  6:54 ` Fix build ID parsing logic in stable trees Greg KH
2024-11-05  9:15   ` Jiri Olsa
2024-11-06  6:12     ` Greg KH
2024-11-06 11:57       ` Jiri Olsa
2024-11-07 20:04         ` Omar Sandoval
2024-11-08  8:35           ` Jiri Olsa
2024-11-08 23:26             ` Jiri Olsa
2024-11-13 20:07               ` Andrii Nakryiko
2024-11-13 21:12                 ` Jiri Olsa
2024-11-15 18:19                   ` Omar Sandoval
2024-11-19 11:58                     ` Greg KH
2024-11-19 15:22                       ` Jiri Olsa
2024-11-08 17:55           ` Andrii Nakryiko

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=20241104175256.2327164-2-jolsa@kernel.org \
    --to=jolsa@kernel.org \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=stable@vger.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