Patch "perf tools: Fix build-id event recording" has been added to the 6.12-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    perf tools: Fix build-id event recording

to the 6.12-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     perf-tools-fix-build-id-event-recording.patch
and it can be found in the queue-6.12 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 9aa58caa1c895fb1b9337019c5d238fb79a14de7
Author: Namhyung Kim <namhyung@xxxxxxxxxx>
Date:   Tue Nov 26 19:13:31 2024 -0800

    perf tools: Fix build-id event recording
    
    [ Upstream commit 23c44f6c83257923b179461694edcf62749bedd5 ]
    
    The build-id events written at the end of the record session are broken
    due to unexpected data.  The write_buildid() writes the fixed length
    event first and then variable length filename.
    
    But a recent change made it write more data in the padding area
    accidentally.  So readers of the event see zero-filled data for the
    next entry and treat it incorrectly.  This resulted in wrong kernel
    symbols because the kernel DSO loaded a random vmlinux image in the
    path as it didn't have a valid build-id.
    
    Fixes: ae39ba16554e ("perf inject: Fix build ID injection")
    Reported-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
    Tested-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
    Reviewed-by: Ian Rogers <irogers@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/Z0aRFFW9xMh3mqKB@xxxxxxxxxx
    Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index 8982f68e7230..e763e8d99a43 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -277,7 +277,7 @@ static int write_buildid(const char *name, size_t name_len, struct build_id *bid
 	struct perf_record_header_build_id b;
 	size_t len;
 
-	len = sizeof(b) + name_len + 1;
+	len = name_len + 1;
 	len = PERF_ALIGN(len, sizeof(u64));
 
 	memset(&b, 0, sizeof(b));
@@ -286,7 +286,7 @@ static int write_buildid(const char *name, size_t name_len, struct build_id *bid
 	misc |= PERF_RECORD_MISC_BUILD_ID_SIZE;
 	b.pid = pid;
 	b.header.misc = misc;
-	b.header.size = len;
+	b.header.size = sizeof(b) + len;
 
 	err = do_write(fd, &b, sizeof(b));
 	if (err < 0)




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux