Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932407AbbFQSYY (ORCPT ); Wed, 17 Jun 2015 14:24:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33895 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755154AbbFQSYR (ORCPT ); Wed, 17 Jun 2015 14:24:17 -0400 Date: Wed, 17 Jun 2015 20:24:07 +0200 From: Jiri Olsa To: Wang Nan Cc: acme@kernel.org, namhyung@kernel.org, masami.hiramatsu.pt@hitachi.com, a.p.zijlstra@chello.nl, mingo@redhat.com, jolsa@kernel.org, linux-kernel@vger.kernel.org, pi3orama@163.com, lizefan@huawei.com Subject: Re: [PATCH v2] perf tools: Fix a problem when opening old perf.data with different byte order Message-ID: <20150617182407.GA18600@krava> References: <20150617084616.GA8535@krava.redhat.com> <1434534999-85347-1-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1434534999-85347-1-git-send-email-wangnan0@huawei.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1946 Lines: 47 On Wed, Jun 17, 2015 at 09:56:39AM +0000, Wang Nan wrote: > Following error occurs when trying to use 'perf report' on x86_64 to > cross analysis a perf.data generated by an old perf on a big-endian > machine: > > # perf report > *** Error in `/home/w00229757/perf': free(): invalid next size (fast): 0x00000000032c99f0 *** > ======= Backtrace: ========= > /lib64/libc.so.6(+0x6eeef)[0x7ff6ff7e2eef] > /lib64/libc.so.6(+0x78cae)[0x7ff6ff7eccae] > /lib64/libc.so.6(+0x79987)[0x7ff6ff7ed987] > /path/to/perf[0x4ac734] > /path/to/perf[0x4ac829] > /path/to/perf(perf_header__process_sections+0x129)[0x4ad2c9] > /path/to/perf(perf_session__read_header+0x2e1)[0x4ad9e1] > /path/to/perf(perf_session__new+0x168)[0x4bd458] > /path/to/perf(cmd_report+0xfa0)[0x43eb70] > /path/to/perf[0x47adc3] > /path/to/perf(main+0x5f6)[0x42fd06] > /lib64/libc.so.6(__libc_start_main+0xf5)[0x7ff6ff795bd5] > /path/to/perf[0x42fe35] > ======= Memory map: ======== > [SNIP] > > The bug is in perf_event__attr_swap(). It swaps all fields in > 'struct perf_event_attr' without checking whether the swapped field > exist or not. In addition, in read_event_desc() allocs memory for attr > according to size read from perf.data. Therefore, if the perf.data is > collected by an old perf (without aux_watermark, for example), > when perf_event__attr_swap() swaping attr->aux_watermark it destroy > malloc's metadata. > > This patch introduces boundary checking in perf_event__attr_swap(). It > adds macros bswap_field_64 and bswap_field_32 into > perf_event__attr_swap() to make it only swap exist fields. > > Signed-off-by: Wang Nan Acked-by: Jiri Olsa thanks, jirka -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/