lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190702103420.27540-2-leo.yan@linaro.org>
Date:   Tue,  2 Jul 2019 18:34:10 +0800
From:   Leo Yan <leo.yan@...aro.org>
To:     Arnaldo Carvalho de Melo <acme@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...hat.com>,
        Namhyung Kim <namhyung@...nel.org>,
        Mathieu Poirier <mathieu.poirier@...aro.org>,
        Suzuki K Poulose <suzuki.poulose@....com>,
        Andi Kleen <ak@...ux.intel.com>,
        "David S. Miller" <davem@...emloft.net>,
        Davidlohr Bueso <dave@...olabs.net>,
        Rasmus Villemoes <linux@...musvillemoes.dk>,
        Jin Yao <yao.jin@...ux.intel.com>,
        Song Liu <songliubraving@...com>,
        Adrian Hunter <adrian.hunter@...el.com>,
        Alexios Zavras <alexios.zavras@...el.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Changbin Du <changbin.du@...el.com>,
        Eric Saint-Etienne <eric.saint.etienne@...cle.com>,
        Konstantin Khlebnikov <khlebnikov@...dex-team.ru>,
        Thomas Richter <tmricht@...ux.ibm.com>,
        Alexey Budankov <alexey.budankov@...ux.intel.com>,
        linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org
Cc:     Leo Yan <leo.yan@...aro.org>
Subject: [PATCH v1 01/11] perf report: Smatch: Fix potential NULL pointer dereference

Based on the following report from Smatch, fix the potential
NULL pointer dereference check.

  tools/perf/builtin-report.c:304
  process_read_event() error: we previously assumed 'evsel' could be null (see line 301)

tools/perf/builtin-report.c
301                 const char *name = evsel ? perf_evsel__name(evsel) : "unknown";
302                 int err = perf_read_values_add_value(&rep->show_threads_values,
303                                            event->read.pid, event->read.tid,
304                                            evsel->idx,
                                               ^^^^^^^
305                                            name,
306                                            event->read.value);

This patch checks if 'evsel' is NULL pointer then pass UINT64_MAX as idx
parameter.

Signed-off-by: Leo Yan <leo.yan@...aro.org>
---
 tools/perf/builtin-report.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 91c40808380d..a894ce7cd04e 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -299,10 +299,10 @@ static int process_read_event(struct perf_tool *tool,
 
 	if (rep->show_threads) {
 		const char *name = evsel ? perf_evsel__name(evsel) : "unknown";
+		int idx = evsel ? evsel->idx : INT_MAX;
 		int err = perf_read_values_add_value(&rep->show_threads_values,
 					   event->read.pid, event->read.tid,
-					   evsel->idx,
-					   name,
+					   idx, name,
 					   event->read.value);
 
 		if (err)
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ