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]
Date:	Tue, 8 Dec 2015 02:25:44 +0000
From:	Wang Nan <wangnan0@...wei.com>
To:	<acme@...nel.org>, <namhyung@...nel.org>
CC:	<linux-kernel@...r.kernel.org>, <pi3orama@....com>,
	<mingo@...nel.org>, <lizefan@...wei.com>,
	Wang Nan <wangnan0@...wei.com>,
	"Arnaldo Carvalho de Melo" <acme@...hat.com>,
	Jiri Olsa <jolsa@...hat.com>
Subject: [PATCH v4 16/16] perf tools: Clear struct machine during machine__init()

There are so many test cases use stack allocated 'struct machine'.
Including:
  test__hists_link
  test__hists_filter
  test__mmap_thread_lookup
  test__thread_mg_share
  test__hists_output
  test__hists_cumulate

Also, in non-test code (for example, machine__new_host()) there are
code use 'malloc()' to alloc struct machine.

These are dangerous operations, cause some tests fail or hung in
machines__exit(). For example, in

 machines__exit ->
   machine__destroy_kernel_maps ->
     map_groups__remove ->
       maps__remove ->
         pthread_rwlock_wrlock

a incorrectly initialized lock causes unintended behavior.

This patch bzero() that structure in machine__init() to ensure all
fields in 'struct machine' are initialized to zero.

Signed-off-by: Wang Nan <wangnan0@...wei.com>
Cc: Arnaldo Carvalho de Melo <acme@...hat.com>
Cc: Jiri Olsa <jolsa@...hat.com>
Cc: Namhyung Kim <namhyung@...nel.org>
---
 tools/perf/util/machine.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index bfc289c..188cfdf 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -25,6 +25,7 @@ static void dsos__init(struct dsos *dsos)
 
 int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
 {
+	bzero(machine, sizeof(*machine));
 	map_groups__init(&machine->kmaps, machine);
 	RB_CLEAR_NODE(&machine->rb_node);
 	dsos__init(&machine->dsos);
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ