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: <1272419560-4332-3-git-send-email-acme@infradead.org>
Date:	Tue, 27 Apr 2010 22:52:37 -0300
From:	Arnaldo Carvalho de Melo <acme@...radead.org>
To:	Ingo Molnar <mingo@...e.hu>
Cc:	linux-kernel@...r.kernel.org,
	Arnaldo Carvalho de Melo <acme@...hat.com>,
	Avi Kivity <avi@...hat.com>,
	Frédéric Weisbecker <fweisbec@...il.com>,
	Mike Galbraith <efault@....de>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Paul Mackerras <paulus@...ba.org>,
	"Zhang, Yanmin" <yanmin_zhang@...ux.intel.com>
Subject: [PATCH 2/5] perf machine: Pass buffer size to machine__mmap_name

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

Don't blindly assume that the size of the buffer is enough, use
snprintf.

Cc: Avi Kivity <avi@...hat.com>
Cc: Frédéric Weisbecker <fweisbec@...il.com>
Cc: Mike Galbraith <efault@....de>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc: Paul Mackerras <paulus@...ba.org>
Cc: Zhang, Yanmin <yanmin_zhang@...ux.intel.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
 tools/perf/util/event.c  |    4 ++--
 tools/perf/util/map.c    |   10 +++++-----
 tools/perf/util/map.h    |    2 +-
 tools/perf/util/symbol.c |    6 +++---
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 2f33ca9..7400e51 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -288,7 +288,7 @@ int event__synthesize_kernel_mmap(event__handler_t process,
 	 */
 	struct process_symbol_args args = { .name = symbol_name, };
 
-	mmap_name = machine__mmap_name(machine, name_buff);
+	mmap_name = machine__mmap_name(machine, name_buff, sizeof(name_buff));
 	if (machine__is_host(machine)) {
 		/*
 		 * kernel uses PERF_RECORD_MISC_USER for user space maps,
@@ -399,7 +399,7 @@ static int event__process_kernel_mmap(event_t *self,
 		goto out_problem;
 	}
 
-	machine__mmap_name(machine, kmmap_prefix);
+	machine__mmap_name(machine, kmmap_prefix, sizeof(kmmap_prefix));
 	if (machine__is_host(machine))
 		kernel_type = DSO_TYPE_KERNEL;
 	else
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index da3d4e8..ee25ee9 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -629,14 +629,14 @@ void machines__process(struct rb_root *self, machine__process_t process, void *d
 	}
 }
 
-char *machine__mmap_name(struct machine *self, char *buff)
+char *machine__mmap_name(struct machine *self, char *bf, size_t size)
 {
 	if (machine__is_host(self))
-		sprintf(buff, "[%s]", "kernel.kallsyms");
+		snprintf(bf, size, "[%s]", "kernel.kallsyms");
 	else if (machine__is_default_guest(self))
-		sprintf(buff, "[%s]", "guest.kernel.kallsyms");
+		snprintf(bf, size, "[%s]", "guest.kernel.kallsyms");
 	else
-		sprintf(buff, "[%s.%d]", "guest.kernel.kallsyms", self->pid);
+		snprintf(bf, size, "[%s.%d]", "guest.kernel.kallsyms", self->pid);
 
-	return buff;
+	return bf;
 }
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index 4c1c2da..6fabad1 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -133,7 +133,7 @@ struct machine *machines__add(struct rb_root *self, pid_t pid,
 struct machine *machines__find_host(struct rb_root *self);
 struct machine *machines__find(struct rb_root *self, pid_t pid);
 struct machine *machines__findnew(struct rb_root *self, pid_t pid);
-char *machine__mmap_name(struct machine *self, char *buff);
+char *machine__mmap_name(struct machine *self, char *bf, size_t size);
 
 /*
  * Default guest kernel is defined by parameter --guestkallsyms
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index dc04636..c9c0bdd 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1856,7 +1856,7 @@ static int dso__load_guest_kernel_sym(struct dso *self, struct map *map,
 out_try_fixup:
 	if (err > 0) {
 		if (kallsyms_filename != NULL) {
-			machine__mmap_name(machine, path);
+			machine__mmap_name(machine, path, sizeof(path));
 			dso__set_long_name(self, strdup(path));
 		}
 		map__fixup_start(map);
@@ -1961,8 +1961,8 @@ struct dso *dso__new_kernel(const char *name)
 static struct dso *dso__new_guest_kernel(struct machine *machine,
 					const char *name)
 {
-	char buff[PATH_MAX];
-	struct dso *self = dso__new(name ?: machine__mmap_name(machine, buff));
+	char bf[PATH_MAX];
+	struct dso *self = dso__new(name ?: machine__mmap_name(machine, bf, sizeof(bf)));
 
 	if (self != NULL) {
 		dso__set_short_name(self, "[guest.kernel]");
-- 
1.6.2.5

--
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