lkml.org 
[lkml]   [2017]   [Aug]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.9 087/105] perf symbols: Robustify reading of build-id from sysfs
    Date
    4.9-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Arnaldo Carvalho de Melo <acme@redhat.com>


    [ Upstream commit 7934c98a6e04028eb34c1293bfb5a6b0ab630b66 ]

    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>
    Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ---
    tools/perf/util/symbol-elf.c | 6 ++++++
    1 file changed, 6 insertions(+)

    --- 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 *fil
    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;
    }

    \
     
     \ /
      Last update: 2017-08-05 01:24    [W:4.049 / U:0.140 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site