From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933611AbcHDJbm (ORCPT ); Thu, 4 Aug 2016 05:31:42 -0400 Received: from terminus.zytor.com ([198.137.202.10]:52042 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933335AbcHDJaI (ORCPT ); Thu, 4 Aug 2016 05:30:08 -0400 Date: Thu, 4 Aug 2016 02:09:51 -0700 From: tip-bot for Arnaldo Carvalho de Melo Message-ID: Cc: acme@redhat.com, mingo@kernel.org, hpa@zytor.com, adrian.hunter@intel.com, tglx@linutronix.de, dsahern@gmail.com, linux-kernel@vger.kernel.org, jolsa@kernel.org, wangnan0@huawei.com, namhyung@kernel.org Reply-To: hpa@zytor.com, mingo@kernel.org, acme@redhat.com, adrian.hunter@intel.com, tglx@linutronix.de, dsahern@gmail.com, linux-kernel@vger.kernel.org, jolsa@kernel.org, wangnan0@huawei.com, namhyung@kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf annotate: Plug filename string leak Git-Commit-ID: c17c17e8c26a5d44b3a8a6ef8c55233d72eed6c0 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: c17c17e8c26a5d44b3a8a6ef8c55233d72eed6c0 Gitweb: http://git.kernel.org/tip/c17c17e8c26a5d44b3a8a6ef8c55233d72eed6c0 Author: Arnaldo Carvalho de Melo AuthorDate: Mon, 1 Aug 2016 18:49:13 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 1 Aug 2016 18:49:13 -0300 perf annotate: Plug filename string leak If dso__build_id_filename(..., NULL, ...) returns !NULL its because it allocated it, so, when reaching the 'if (dso__is_kcore()) test, we already checked that and were just "fallbacking" to using dso->long_name, but without freeing filename, thus leaking it. Fix it by adding the dso__is_kcore() test to the 'or' group just after it, the one containing the full fallback code, including freeing the filename. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Fixes: ee205503f233 ("perf tools: Fix annotation with kcore") Link: http://lkml.kernel.org/n/tip-qi4rpjq8yo6myvg99kkgt0xz@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/annotate.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 4982ed4..4024d30 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1185,9 +1185,8 @@ int symbol__disassemble(struct symbol *sym, struct map *map, size_t privsize) if (dso->has_build_id) return ENOMEM; goto fallback; - } else if (dso__is_kcore(dso)) { - goto fallback; - } else if (readlink(symfs_filename, command, sizeof(command)) < 0 || + } else if (dso__is_kcore(dso) || + readlink(symfs_filename, command, sizeof(command)) < 0 || strstr(command, DSO__NAME_KALLSYMS) || access(symfs_filename, R_OK)) { free(filename);