public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for David Ahern <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: acme@redhat.com, linux-kernel@vger.kernel.org, hpa@zytor.com,
	mingo@kernel.org, peterz@infradead.org, namhyung@kernel.org,
	jolsa@redhat.com, fweisbec@gmail.com, dsahern@gmail.com,
	tglx@linutronix.de
Subject: [tip:perf/urgent] perf evsel: Fix count parameter to read call in event_format__new
Date: Fri, 12 Jul 2013 01:51:17 -0700	[thread overview]
Message-ID: <tip-7cab84e8975cfb8a59ce3e79ce75e5eedd384484@git.kernel.org> (raw)
In-Reply-To: <1372793245-4136-2-git-send-email-dsahern@gmail.com>

Commit-ID:  7cab84e8975cfb8a59ce3e79ce75e5eedd384484
Gitweb:     http://git.kernel.org/tip/7cab84e8975cfb8a59ce3e79ce75e5eedd384484
Author:     David Ahern <dsahern@gmail.com>
AuthorDate: Tue, 2 Jul 2013 13:27:20 -0600
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 8 Jul 2013 17:40:39 -0300

perf evsel: Fix count parameter to read call in event_format__new

per realloc above the length of the buffer is alloc_size, not BUFSIZ.
Adjust length per size as done for buf start.

Addresses some valgrind complaints:

==1870== Syscall param read(buf) points to unaddressable byte(s)
==1870==    at 0x4E3F610: __read_nocancel (in /lib64/libpthread-2.14.90.so)
==1870==    by 0x44AEE1: event_format__new (unistd.h:45)
==1870==    by 0x44B025: perf_evsel__newtp (evsel.c:158)
==1870==    by 0x451919: add_tracepoint_event (parse-events.c:395)
==1870==    by 0x479815: parse_events_parse (parse-events.y:292)
==1870==    by 0x45463A: parse_events_option (parse-events.c:861)
==1870==    by 0x44FEE4: get_value (parse-options.c:113)
==1870==    by 0x450767: parse_options_step (parse-options.c:192)
==1870==    by 0x450C40: parse_options (parse-options.c:422)
==1870==    by 0x42735F: cmd_record (builtin-record.c:918)
==1870==    by 0x419D72: run_builtin (perf.c:319)
==1870==    by 0x4195F2: main (perf.c:376)
==1870==  Address 0xcffebf0 is 0 bytes after a block of size 8,192 alloc'd
==1870==    at 0x4C2A62F: malloc (vg_replace_malloc.c:270)
==1870==    by 0x4C2A7A3: realloc (vg_replace_malloc.c:662)
==1870==    by 0x44AF07: event_format__new (evsel.c:121)
==1870==    by 0x44B025: perf_evsel__newtp (evsel.c:158)
==1870==    by 0x451919: add_tracepoint_event (parse-events.c:395)
==1870==    by 0x479815: parse_events_parse (parse-events.y:292)
==1870==    by 0x45463A: parse_events_option (parse-events.c:861)
==1870==    by 0x44FEE4: get_value (parse-options.c:113)
==1870==    by 0x450767: parse_options_step (parse-options.c:192)
==1870==    by 0x450C40: parse_options (parse-options.c:422)
==1870==    by 0x42735F: cmd_record (builtin-record.c:918)
==1870==    by 0x419D72: run_builtin (perf.c:319)

Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1372793245-4136-2-git-send-email-dsahern@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/evsel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 63b6f8c..df99ebe 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -124,7 +124,7 @@ struct event_format *event_format__new(const char *sys, const char *name)
 			bf = nbf;
 		}
 
-		n = read(fd, bf + size, BUFSIZ);
+		n = read(fd, bf + size, alloc_size - size);
 		if (n < 0)
 			goto out_free_bf;
 		size += n;

  reply	other threads:[~2013-07-12  8:51 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-02 19:27 [PATCH 0/6] perf: bug fixes, cleanup of parse events memory allocations David Ahern
2013-07-02 19:27 ` [PATCH 1/6] perf evsel: fix count parameter to read call in event_format__new David Ahern
2013-07-12  8:51   ` tip-bot for David Ahern [this message]
2013-07-02 19:27 ` [PATCH 2/6] perf evlist: fix use of uninitialized variable David Ahern
2013-07-19  7:44   ` [tip:perf/core] perf evlist: Fix " tip-bot for David Ahern
2013-07-02 19:27 ` [PATCH 3/6] perf event: initialize allocated memory for synthesized events David Ahern
2013-07-11 16:35   ` David Ahern
2013-07-02 19:27 ` [PATCH 4/6] perf: don't free list head in parse_events__free_terms David Ahern
2013-07-19  7:45   ` [tip:perf/core] perf tools: Don' t " tip-bot for David Ahern
2013-07-02 19:27 ` [PATCH 5/6] perf test: make terms a stack variable in test_term David Ahern
2013-07-19  7:45   ` [tip:perf/core] perf tests: Make " tip-bot for David Ahern
2013-07-02 19:27 ` [PATCH 6/6] perf parse events: demystify memory allocations David Ahern
2013-07-07 15:26   ` Jiri Olsa
2013-07-07 16:45     ` David Ahern
2013-07-07 17:00       ` Jiri Olsa
2013-07-19  7:45   ` [tip:perf/core] perf parse events: Demystify " tip-bot for David Ahern
2013-07-05 14:34 ` [PATCH 0/6] perf: bug fixes, cleanup of parse events " Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-7cab84e8975cfb8a59ce3e79ce75e5eedd384484@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=acme@redhat.com \
    --cc=dsahern@gmail.com \
    --cc=fweisbec@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox