Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1753903imm; Thu, 9 Aug 2018 01:08:28 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyIfTc0LVbCCyolkapFsGr4yZGVb/8ele6UfkigjQZFTnmKM3f0i5aNQoJ5ofyN9vYlKUcL X-Received: by 2002:a17:902:9a8b:: with SMTP id w11-v6mr1091301plp.333.1533802108380; Thu, 09 Aug 2018 01:08:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533802108; cv=none; d=google.com; s=arc-20160816; b=iBFVnGeKltTJZMu9otb7qvuROUUwWNEdo+LJVztyAMOW/6oih5H4Pj/ITVBl9/Hd4k 90x0FgmqYbVWqfwA7zOzqrRp6jldxJGa2Zqvv6WcaZF2UWl9WrQmxPzD8ceVHlJJWDX1 ZNerv28Jnh8JW27LAzYV8gsivcUOeuGwi8P+DG3yoYXk2L+xCfG+ppG7UvIR2o4I53qw RsFTYJ0Fw4ItUzmWJgt083Lk4qL4nmRoNH63M8gAOyg4RUSoeYnF/N5Scxgtv+QNgmcp bxsSnsUIzlBCooRv2tCBeO4LBX26wEmgPXEExMJvxUgC0RlnMyxNwOEfpt0P35gzKCDL YvYQ== 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=Hxa+9H0b3RX5GiiVnL+pN0eAuSHY+dVVBPBulAGefuM=; b=bU9/qp9gnE8Vu2du92sU/spYcfd1bWM++civO5Ounv+XjvuHYdoug4CCsO9qrKGRPT SXOXhjgl/sKOq3+8NAhNzOAYa1IZcsS303nmigjRc2DJQAzLArJ/09rVQz0UEEimf+9m RMXQmstU1V/gAO6m68Uh9j7DlV0tsWgJtuXCuKbrQk1hznK3XKXW8ANKh6u/R5xFRhqt UJLOYOBG5SRRYNRo7SPpzB2oHStc811PMYztoLIdlNEO1Pn8qKMGGU8KXH/TKrvbIYmo RbVXEdXORg0Lk4WO4ldBW/xKItgSKpJVuQGitgsi4njcVRzjf5NPfayregby/Ml2+5aN PVaA== 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 e186-v6si6909658pfa.107.2018.08.09.01.08.11; Thu, 09 Aug 2018 01:08:28 -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 S1729413AbeHIKbF (ORCPT + 99 others); Thu, 9 Aug 2018 06:31:05 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:32890 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727768AbeHIKbE (ORCPT ); Thu, 9 Aug 2018 06:31:04 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4E72540241DF; Thu, 9 Aug 2018 08:07:24 +0000 (UTC) Received: from krava (unknown [10.40.205.2]) by smtp.corp.redhat.com (Postfix) with SMTP id D8E872026D68; Thu, 9 Aug 2018 08:07:22 +0000 (UTC) Date: Thu, 9 Aug 2018 10:07:22 +0200 From: Jiri Olsa To: Stephane Eranian Cc: linux-kernel@vger.kernel.org, acme@redhat.com, peterz@infradead.org, mingo@elte.hu Subject: Re: [PATCH v2] perf ordered_events: fix crash in free_dup_event() Message-ID: <20180809080721.GB19243@krava> References: <1533767600-7794-1-git-send-email-eranian@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1533767600-7794-1-git-send-email-eranian@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 09 Aug 2018 08:07:24 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 09 Aug 2018 08:07:24 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.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 Wed, Aug 08, 2018 at 03:33:20PM -0700, Stephane Eranian wrote: > This patch fixes a bug in ordered_event.c:alloc_event(). > An ordered_event struct was not initialized properly potentially > causing crashes later on in free_dup_event() depending on the > content of the memory. If it was NULL, then it would work fine, > otherwise, it could cause crashes such as: I'm now little puzzled what do we use this first event for.. I can't see anything special about it, other than it's added on the list uninitialized ;-) it seems to work properly when we ditch it.. might be some prehistoric leftover or I'm terribly missing something thanks, jirka --- diff --cc tools/perf/util/ordered-events.c index bad9e0296e9a,0e837b0b8582..000000000000 --- a/tools/perf/util/ordered-events.c +++ b/tools/perf/util/ordered-events.c @@@ -119,12 -119,8 +119,9 @@@ static struct ordered_event *alloc_even pr("alloc size %" PRIu64 "B (+%zu), max %" PRIu64 "B\n", oe->cur_alloc_size, size, oe->max_alloc_size); + oe->cur_alloc_size += size; - list_add(&oe->buffer->list, &oe->to_free); - - /* First entry is abused to maintain the to_free list. */ - oe->buffer_idx = 2; - new = oe->buffer + 1; + oe->buffer_idx = 1; + new = oe->buffer; } else { pr("allocation limit reached %" PRIu64 "B\n", oe->max_alloc_size); }