From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756886AbdGLHiI (ORCPT ); Wed, 12 Jul 2017 03:38:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33976 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756657AbdGLHiH (ORCPT ); Wed, 12 Jul 2017 03:38:07 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0AE4F7D0E4 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jolsa@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0AE4F7D0E4 Date: Wed, 12 Jul 2017 09:38:02 +0200 From: Jiri Olsa To: David Carrillo-Cisneros Cc: linux-kernel , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Andi Kleen , Simon Que , Wang Nan , Jiri Olsa , He Kuang , Masami Hiramatsu , Stephane Eranian , Paul Turner Subject: Re: [PATCH v4 15/16] perf tools: add feature header record to pipe-mode Message-ID: <20170712073802.GA28985@krava> References: <20170613042932.141842-1-davidcc@google.com> <20170613042932.141842-16-davidcc@google.com> <20170613185454.GE6092@krava> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.8.3 (2017-05-23) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 12 Jul 2017 07:38:06 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 11, 2017 at 05:32:40PM -0700, David Carrillo-Cisneros wrote: > On Tue, Jun 13, 2017 at 11:54 AM, Jiri Olsa wrote: > > On Mon, Jun 12, 2017 at 09:29:31PM -0700, David Carrillo-Cisneros wrote: > > > > SNIP > > > >> > >> void perf_event__print_totals(void); > >> diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c > >> index ddfaf157913d..6f6a54c15cb0 100644 > >> --- a/tools/perf/util/header.c > >> +++ b/tools/perf/util/header.c > >> @@ -34,6 +34,7 @@ > >> #include "data.h" > >> #include > >> #include "asm/bug.h" > >> +#include "tool.h" > >> > >> #include "sane_ctype.h" > >> > >> @@ -97,11 +98,14 @@ static int __do_write_buf(struct feat_fd *ff, const void *buf, size_t size) > >> > >> retry: > >> if (size > (ff->size - ff->offset)) { > >> - addr = realloc(ff->buf, ff->size << 1); > >> + size = ff->size << 1; > >> + if (size > page_size) > > > > event size could be 0xffff - sizeof(struct perf_event_header) > > also the initial size is most likely > page_size anyway > > > > please put this into the patch that introduced __do_write_buf > > > > Thank you for reviewing this. I just realized that I sent v5 without > properly addressing this issue. In v4 I tried to add a quick check > without properly understanding the issue. Why is 0xffff the maximum > size for an event? where is this constraint coming from? the struct perf_event_header::size is u16 jirka