Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754183AbcJMLB6 (ORCPT ); Thu, 13 Oct 2016 07:01:58 -0400 Received: from mail-qk0-f181.google.com ([209.85.220.181]:36598 "EHLO mail-qk0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753765AbcJMLB2 (ORCPT ); Thu, 13 Oct 2016 07:01:28 -0400 From: Stephane Eranian To: linux-kernel@vger.kernel.org Cc: acme@kernel.org, jolsa@redhat.com, peterz@infradead.org, mingo@elte.hu, anton@ozlabs.org, namhyung@kernel.org, Stefano Sanfilippo , Ross McIlroy Subject: [PATCH 8/9] perf/jit: Check JITHEADER_VERSION Date: Thu, 13 Oct 2016 03:59:42 -0700 Message-Id: <1476356383-30100-9-git-send-email-eranian@google.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1476356383-30100-1-git-send-email-eranian@google.com> References: <1476356383-30100-1-git-send-email-eranian@google.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1047 Lines: 31 From: Stefano Sanfilippo Check the version number when opening a jitdump file. Accept older versions, but not newer ones. Signed-off-by: Stefano Sanfilippo Signed-off-by: Ross McIlroy Reviewed-by: Stephane Eranian --- 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 c47fba63274b..c5dabb3a81fd 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); -- 1.9.1