Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4481669imm; Tue, 7 Aug 2018 02:09:51 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf4H3X8fHvwzwyeKAu+NcMvmo1bfqfv3BxgpZ56j9P7NKf7jdRQDmaOwNGFTCsx4P6ml7bQ X-Received: by 2002:a62:954:: with SMTP id e81-v6mr20895721pfd.231.1533632991677; Tue, 07 Aug 2018 02:09:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533632991; cv=none; d=google.com; s=arc-20160816; b=eIiQOsNxFlubWzPGIbG0FUWnMGWMsyB4aa7F/I9Wdrv8PJVioVLRTJFkE0F60LQF8H nWHW/+NkSKUvUxWDofrHnqMjCIRyylBE0/EQNEd7VkQk5OmXGWwb4PZzGtcZvik0kkiB SJraTt4u3I2wSt3XunQffBDWAr6vEuRNe0S3mmDJG48ayyLxzrIyaKXB0JEdDX1QQVL8 qF4k4nCURWZGMy40YCT07bL0atevUp+8PWBqy9BZmcjz2jx/IE4iFlhkrVtWxOdqyv4b wYzgn3HBrlPpstBSiHNvYSm3n2ipopsGg2IRx0ckHKZrcQliBIFlHY4gkaeUM3nAD/9D k/dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=xGm0ATlQeNn/NJ8+KX0DeFInNnvZKmrfWaxWl3XJ1F8=; b=gfdF/QzdT3jsbUfzFJfucso8JqB/wIx/7lgHTZuRjFRgkwUALyJ3HMbQhUMWk0e9DF xAiozupKAlA2YQB8k9OZ5F/hKykvPlR6ojTCE7z2ll2LjyofNE2mbtFt5jIWSyCKFUGb W/S2vYgdq+qQMqEPhI3krzlJyrSLO+YKVc+OAiw61dEqJXb6Af38e7W5sPQcPUgiLh+G /HjpScUPUMoM3PAwZg/KBOkZT03/IVQlaWltGD/D4DJ2DQDz0ud/shDZ1p4UJS7GZFBJ z+odXbMEy1oY4V2aLlAGLHYrZ9ni3j/bf3H+1GIb8GOG5fz0jSY4M1FUCQt9bcg8WXDH Lxnw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v65-v6si957654pfk.261.2018.08.07.02.09.37; Tue, 07 Aug 2018 02:09:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387428AbeHGLDa (ORCPT + 99 others); Tue, 7 Aug 2018 07:03:30 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:36140 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727578AbeHGLDa (ORCPT ); Tue, 7 Aug 2018 07:03:30 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5DA987C809; Tue, 7 Aug 2018 08:50:12 +0000 (UTC) Received: from krava (unknown [10.43.17.214]) by smtp.corp.redhat.com (Postfix) with SMTP id 68C28215670D; Tue, 7 Aug 2018 08:50:11 +0000 (UTC) Date: Tue, 7 Aug 2018 10:50:10 +0200 From: Jiri Olsa To: Stephane Eranian Cc: LKML , Arnaldo Carvalho de Melo , Peter Zijlstra , mingo@elte.hu Subject: Re: [PATCH] perf ordered_events: fix crash in free_dup_event() Message-ID: <20180807085010.GC7716@krava> References: <1533605015-19514-1-git-send-email-eranian@google.com> <20180807072029.GA7716@krava> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 07 Aug 2018 08:50:12 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 07 Aug 2018 08:50:12 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jolsa@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 07, 2018 at 01:16:22AM -0700, Stephane Eranian wrote: > On Tue, Aug 7, 2018 at 12:20 AM Jiri Olsa wrote: > > > > On Mon, Aug 06, 2018 at 06:23:35PM -0700, Stephane Eranian wrote: > > > Depending on memory allocations, it was possible to get a SEGFAULT in > > > free_dup_event() because the event pointer was bogus: > > > > > > perf[1354]: segfault at ffffffff00000006 ip 00000000004b7fc7 > > > > is there any reproducer? > > > The cmdline is simple: > $ perf record -e cycles:pp -o - -a sleep 1 | perf inject -b -i - >/dev/null > I was using v4.13 for my tests and it may be sensitive to compiler. > Was using LLVM. I can't make it fail even when I compile with clang 'make CC=clang' [jolsa@krava perf]$ clang --version clang version 6.0.1 (tags/RELEASE_601/final) I'm on v4.17, but I dont think kernel version is related to this issue > > It may be a compiler related issue. You do not allocate the whole struct. > If the compiler was to do a memcpy() behind your back, you'd be in > troubles. > > Adding extra padding before *event was also avoiding the problem. > struct ordered_event { > u64 timestamp; > u64 file_offset; > char pad[32]; <----- extra padding for debugging > union perf_event *event; > struct list_head list; > }; might be some issue in the struct ordered_event allocation, which is little convoluted jirka