Skip to contentSkip to conversation

perf tools: Fix /proc/kcore access on 32 bit systems

PATCH Applied James Clark 2 participants 2 messages Oct 21, 2021 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf tools: Fix /proc/kcore access on 32 bit systems

Because _LARGEFILE64_SOURCE is set in perf, file offset sizes can be 64 bits. If a workflow needs to open /proc/kcore on a 32 bit system (for example to decode Arm ETM kernel trace) then the size value will be wrapped to 32 bits in the function file_size() at this line:

  dso->data.file_size = st.st_size;

Setting the file_size member to be u64 fixes the issue and allows /proc/kcore to be opened.

---
 tools/perf/util/dso.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/dso.h +1 -1
index 83723ba11dc8..011da3924fc1 100644
@@ -193,7 +193,7 @@ struct dso {
 		int		 fd;
 		int		 status;
 		u32		 status_seen;
-		size_t		 file_size;
+		u64		 file_size;
 		struct list_head open_entry;
 		u64		 debug_frame_offset;
 		u64		 eh_frame_hdr_offset;
Signature · 1 line
2.28.0
maintainer Applied
#1 lore raw

Em Thu, Oct 21, 2021 at 12:27:00PM +0100, James Clark escreveu:

Quoted 9 lines

Because _LARGEFILE64_SOURCE is set in perf, file offset sizes can be 64 bits. If a workflow needs to open /proc/kcore on a 32 bit system (for example to decode Arm ETM kernel trace) then the size value will be wrapped to 32 bits in the function file_size() at this line:

  dso->data.file_size = st.st_size;

Setting the file_size member to be u64 fixes the issue and allows /proc/kcore to be opened.

Thanks, applied.

- Arnaldo

Quoted 21 lines
---
 tools/perf/util/dso.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/dso.h +1 -1
index 83723ba11dc8..011da3924fc1 100644
@@ -193,7 +193,7 @@ struct dso {
 		int		 fd;
 		int		 status;
 		u32		 status_seen;
-		size_t		 file_size;
+		u64		 file_size;
 		struct list_head open_entry;
 		u64		 debug_frame_offset;
 		u64		 eh_frame_hdr_offset;
Signature · 1 line
2.28.0
Signature · 1 line
- Arnaldo