* [PATCH] perf: header: Check read return
@ 2025-04-07 16:35 James O. D. Hunt
0 siblings, 0 replies; only message in thread
From: James O. D. Hunt @ 2025-04-07 16:35 UTC (permalink / raw)
To: linux-perf-users, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Adrian Hunter, Liang, Kan
Cc: linux-kernel, James O . D . Hunt
Check the `readn()` return value in `read_attr()` if there are remaining
header bytes to read (previously, the return value was being ignored).
Fixes: 69996df486fc3 ("perf tools: Enable reading of perf.data files from different ABI rev")
Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
---
| 5 +++++
1 file changed, 5 insertions(+)
--git a/tools/perf/util/header.c b/tools/perf/util/header.c
index e3cdc3b7b4ab..09dfd95e350c 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -4161,6 +4161,11 @@ static int read_attr(int fd, struct perf_header *ph,
ptr += PERF_ATTR_SIZE_VER0;
ret = readn(fd, ptr, left);
+ if (ret <= 0) {
+ pr_debug("cannot read %zu remaining bytes of header attr\n",
+ left);
+ return -1;
+ }
}
/* read perf_file_section, ids are read in caller */
ret = readn(fd, &f_attr->ids, sizeof(f_attr->ids));
--
2.49.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-04-07 16:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-07 16:35 [PATCH] perf: header: Check read return James O. D. Hunt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®