From: Stefano Sanfilippo <[email protected]>

Check the version number when opening a jitdump file.  Accept older
versions, but not newer ones.

Signed-off-by: Stefano Sanfilippo <[email protected]>
Signed-off-by: Ross McIlroy <[email protected]>
Reviewed-by: Stephane Eranian <[email protected]>
Cc: Anton Blanchard <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: 
http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
 tools/perf/util/jitdump.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c
index 6a2688da3c4a..c9a941ef0f6d 100644
--- a/tools/perf/util/jitdump.c
+++ b/tools/perf/util/jitdump.c
@@ -180,6 +180,12 @@ jit_open(struct jit_buf_desc *jd, const char *name)
                        header.elf_mach,
                        jd->use_arch_timestamp);
 
+       if (header.version > JITHEADER_VERSION) {
+               pr_err("wrong jitdump version %u, expected " 
STR(JITHEADER_VERSION),
+                       header.version);
+               goto error;
+       }
+
        if (header.flags & JITDUMP_FLAGS_RESERVED) {
                pr_err("jitdump file contains invalid or unsupported flags 
0x%llx\n",
                       (unsigned long long)header.flags & 
JITDUMP_FLAGS_RESERVED);
-- 
2.7.4

Reply via email to