From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Adrian Hunter <adrian.hunter@intel.com>,
David Ahern <dsahern@gmail.com>, Jiri Olsa <jolsa@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Wang Nan <wangnan0@huawei.com>
Subject: [PATCH 10/12] perf symbols: Robustify reading of build-id from sysfs
Date: Wed, 4 Jan 2017 14:25:07 -0300 [thread overview]
Message-ID: <20170104172509.27350-11-acme@kernel.org> (raw)
In-Reply-To: <20170104172509.27350-1-acme@kernel.org>
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Markus reported that perf segfaults when reading /sys/kernel/notes from
a kernel linked with GNU gold, due to what looks like a gold bug, so do
some bounds checking to avoid crashing in that case.
Reported-by: Markus Trippelsdorf <markus@trippelsdorf.de>
Report-Link: http://lkml.kernel.org/r/20161219161821.GA294@x4
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-ryhgs6a6jxvz207j2636w31c@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/symbol-elf.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 99400b0e8f2a..adbc6c02c3aa 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -537,6 +537,12 @@ int sysfs__read_build_id(const char *filename, void *build_id, size_t size)
break;
} else {
int n = namesz + descsz;
+
+ if (n > (int)sizeof(bf)) {
+ n = sizeof(bf);
+ pr_debug("%s: truncating reading of build id in sysfs file %s: n_namesz=%u, n_descsz=%u.\n",
+ __func__, filename, nhdr.n_namesz, nhdr.n_descsz);
+ }
if (read(fd, bf, n) != n)
break;
}
--
2.9.3
next prev parent reply other threads:[~2017-01-04 18:10 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-04 17:24 [GIT PULL 00/12] perf/urgent fixes Arnaldo Carvalho de Melo
2017-01-04 17:24 ` [PATCH 01/12] perf sched timehist: Show total scheduling time Arnaldo Carvalho de Melo
2017-01-04 17:24 ` [PATCH 02/12] samples/bpf sock_example: Avoid getting ethhdr from two includes Arnaldo Carvalho de Melo
2017-01-04 17:25 ` [PATCH 03/12] samples/bpf trace_output_user: Remove duplicate sys/ioctl.h include Arnaldo Carvalho de Melo
2017-01-04 17:25 ` [PATCH 04/12] perf probe: Fix to get correct modname from elf header Arnaldo Carvalho de Melo
2017-01-04 17:25 ` [PATCH 05/12] tools lib subcmd: Add OPT_STRING_OPTARG_SET option Arnaldo Carvalho de Melo
2017-01-04 17:25 ` [PATCH 06/12] perf record: Make __record_options static Arnaldo Carvalho de Melo
2017-01-04 17:25 ` [PATCH 07/12] perf record: Fix --switch-output documentation and comment Arnaldo Carvalho de Melo
2017-01-04 17:25 ` [PATCH 08/12] tools lib traceevent: Fix prev/next_prio for deadline tasks Arnaldo Carvalho de Melo
2017-01-04 17:25 ` [PATCH 09/12] perf tools: Install tools/lib/traceevent plugins with install-bin Arnaldo Carvalho de Melo
2017-01-04 17:25 ` Arnaldo Carvalho de Melo [this message]
2017-01-04 17:25 ` [PATCH 11/12] perf probe: Fix --funcs to show correct symbols for offline module Arnaldo Carvalho de Melo
2017-01-04 17:25 ` [PATCH 12/12] perf probe: Fix to probe on gcc generated symbols for offline kernel Arnaldo Carvalho de Melo
2017-01-05 7:36 ` [GIT PULL 00/12] perf/urgent fixes Ingo Molnar
2017-01-05 15:02 ` Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170104172509.27350-11-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=dsahern@gmail.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=wangnan0@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox