1. 30 7月, 2019 11 次提交
  2. 29 7月, 2019 2 次提交
    • N
      perf header: Fix use of unitialized value warning · 20f9781f
      Numfor Mbiziwo-Tiapo 提交于
      When building our local version of perf with MSAN (Memory Sanitizer) and
      running the perf record command, MSAN throws a use of uninitialized
      value warning in "tools/perf/util/util.c:333:6".
      
      This warning stems from the "buf" variable being passed into "write".
      It originated as the variable "ev" with the type union perf_event*
      defined in the "perf_event__synthesize_attr" function in
      "tools/perf/util/header.c".
      
      In the "perf_event__synthesize_attr" function they allocate space with a malloc
      call using ev, then go on to only assign some of the member variables before
      passing "ev" on as a parameter to the "process" function therefore "ev"
      contains uninitialized memory. Changing the malloc call to zalloc to initialize
      all the members of "ev" which gets rid of the warning.
      
      To reproduce this warning, build perf by running:
      make -C tools/perf CLANG=1 CC=clang EXTRA_CFLAGS="-fsanitize=memory\
       -fsanitize-memory-track-origins"
      
      (Additionally, llvm might have to be installed and clang might have to
      be specified as the compiler - export CC=/usr/bin/clang)
      
      then running:
      tools/perf/perf record -o - ls / | tools/perf/perf --no-pager annotate\
       -i - --stdio
      
      Please see the cover letter for why false positive warnings may be
      generated.
      Signed-off-by: NNumfor Mbiziwo-Tiapo <nums@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Drayton <mbd@fb.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/20190724234500.253358-2-nums@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      20f9781f
    • V
      perf header: Fix divide by zero error if f_header.attr_size==0 · 7622236c
      Vince Weaver 提交于
      So I have been having lots of trouble with hand-crafted perf.data files
      causing segfaults and the like, so I have started fuzzing the perf tool.
      
      First issue found:
      
      If f_header.attr_size is 0 in the perf.data file, then perf will crash
      with a divide-by-zero error.
      
      Committer note:
      
      Added a pr_err() to tell the user why the command failed.
      Signed-off-by: NVince Weaver <vincent.weaver@maine.edu>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/alpine.DEB.2.21.1907231100440.14532@macbook-airSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7622236c
  3. 23 7月, 2019 5 次提交
  4. 11 7月, 2019 2 次提交
  5. 10 7月, 2019 14 次提交
  6. 09 7月, 2019 6 次提交
    • L
      perf intel-pt: Fix potential NULL pointer dereference found by the smatch tool · 323fd749
      Leo Yan 提交于
      Based on the following report from Smatch, fix the potential NULL
      pointer dereference check.
      
        tools/perf/util/intel-pt.c:3200
        intel_pt_process_auxtrace_info() error: we previously assumed
        'session->itrace_synth_opts' could be null (see line 3196)
      
        tools/perf/util/intel-pt.c:3206
        intel_pt_process_auxtrace_info() warn: variable dereferenced before
        check 'session->itrace_synth_opts' (see line 3200)
      
        tools/perf/util/intel-pt.c
        3196         if (session->itrace_synth_opts && session->itrace_synth_opts->set) {
        3197                 pt->synth_opts = *session->itrace_synth_opts;
        3198         } else {
        3199                 itrace_synth_opts__set_default(&pt->synth_opts,
        3200                                 session->itrace_synth_opts->default_no_sample);
                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^
        3201                 if (!session->itrace_synth_opts->default_no_sample &&
        3202                     !session->itrace_synth_opts->inject) {
        3203                         pt->synth_opts.branches = false;
        3204                         pt->synth_opts.callchain = true;
        3205                 }
        3206                 if (session->itrace_synth_opts)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
        3207                         pt->synth_opts.thread_stack =
        3208                                 session->itrace_synth_opts->thread_stack;
        3209         }
      
      'session->itrace_synth_opts' is impossible to be a NULL pointer in
      intel_pt_process_auxtrace_info(), thus this patch removes the NULL test
      for 'session->itrace_synth_opts'.
      Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Acked-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/20190708143937.7722-4-leo.yan@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      323fd749
    • L
      perf intel-bts: Fix potential NULL pointer dereference found by the smatch tool · 1d481458
      Leo Yan 提交于
      Based on the following report from Smatch, fix the potential NULL
      pointer dereference check.
      
        tools/perf/util/intel-bts.c:898
        intel_bts_process_auxtrace_info() error: we previously assumed
        'session->itrace_synth_opts' could be null (see line 894)
      
        tools/perf/util/intel-bts.c:899
        intel_bts_process_auxtrace_info() warn: variable dereferenced before
        check 'session->itrace_synth_opts' (see line 898)
      
        tools/perf/util/intel-bts.c
        894         if (session->itrace_synth_opts && session->itrace_synth_opts->set) {
        895                 bts->synth_opts = *session->itrace_synth_opts;
        896         } else {
        897                 itrace_synth_opts__set_default(&bts->synth_opts,
        898                                 session->itrace_synth_opts->default_no_sample);
                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^
        899                 if (session->itrace_synth_opts)
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^
        900                         bts->synth_opts.thread_stack =
        901                                 session->itrace_synth_opts->thread_stack;
        902         }
      
      'session->itrace_synth_opts' is impossible to be a NULL pointer in
      intel_bts_process_auxtrace_info(), thus this patch removes the NULL test
      for 'session->itrace_synth_opts'.
      Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Acked-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/20190708143937.7722-3-leo.yan@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1d481458
    • L
      perf cs-etm: Fix potential NULL pointer dereference found by the smatch · 0702f23c
      Leo Yan 提交于
      tool
      
      Based on the following report from Smatch, fix the potential NULL
      pointer dereference check.
      
        tools/perf/util/cs-etm.c:2545
        cs_etm__process_auxtrace_info() error: we previously assumed
        'session->itrace_synth_opts' could be null (see line 2541)
      
        tools/perf/util/cs-etm.c
        2541         if (session->itrace_synth_opts && session->itrace_synth_opts->set) {
        2542                 etm->synth_opts = *session->itrace_synth_opts;
        2543         } else {
        2544                 itrace_synth_opts__set_default(&etm->synth_opts,
        2545                                 session->itrace_synth_opts->default_no_sample);
                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^
        2546                 etm->synth_opts.callchain = false;
        2547         }
      
      'session->itrace_synth_opts' is impossible to be a NULL pointer in
      cs_etm__process_auxtrace_info(), thus this patch removes the NULL
      test for 'session->itrace_synth_opts'.
      Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Reviewed-by: NMathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/20190708143937.7722-5-leo.yan@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0702f23c
    • L
      perf parse-events: Remove unused variable: error · 72de3fd9
      Luke Mujica 提交于
      Remove the 'error' variable because it is declared but not used in
      parse-events.y or in the generated parse-events.c.
      Signed-off-by: NLuke Mujica <lukemujica@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/20190703222509.109616-2-lukemujica@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      72de3fd9
    • L
      perf parse-events: Remove unused variable 'i' · 34c9af57
      Luke Mujica 提交于
      Remove the 'int i' because it is declared but not used in parse-events.y
      or in the generated parse-events.c.
      Signed-off-by: NLuke Mujica <lukemujica@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/20190703222509.109616-1-lukemujica@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      34c9af57
    • A
      perf metricgroup: Add missing list_del_init() when flushing egroups list · acc7bfb3
      Arnaldo Carvalho de Melo 提交于
      So that at the end each of the entries have its list node struct cleared
      and the egroup list head ends emptied.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-dxzj1ah350fy9ec0xbhb15b6@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      acc7bfb3