Received: by 10.213.65.68 with SMTP id h4csp464252imn; Fri, 16 Mar 2018 08:32:23 -0700 (PDT) X-Google-Smtp-Source: AG47ELuexDPs8q5eT8w5Q3DjeGEo0y7HDEM3C8vZu72J70HD6cBIdS1N+F4UjBKvIn9GJ0Ll/A3I X-Received: by 2002:a17:902:7142:: with SMTP id u2-v6mr2580111plm.257.1521214343188; Fri, 16 Mar 2018 08:32:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521214343; cv=none; d=google.com; s=arc-20160816; b=jddLtdHeeEEzJ+gCvcNmFMLloTvTI4YlwmdluuDKJ0ag52IRUid3hSJvP9nbcm0pCE /1jQeG5Wh5/HtiZVleAb1jgQzzE6KX1jU/M72zaa45rmfdkeoQFPsGqqCqDAdX0+2ZPT aFd57eYYOc/AYjcuVOqLRjWV6S+/AUrYZx6GcWD5oWlWXNBH6uLOF8DbyHcyYmUKIGEi ddAy8OMl4GPhA73xwEWAOm4MuDBIhl6ygaXdsvVJD5Kc2C6Nok9E0YzdKzjs0Zs8h0fF RLrJsHw3otlFYEhH0FESQa4jjvyh+coMuUiYjPBp5zA4zND5oIZuZqD03HfT/jl52UAJ fuPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=NoXh2sbdYVaiVRvutvhZj5SEvOIjJw9lXgTNYEBrjvY=; b=PE8VpxBGravFk/xKcvdoRhtabMAYquhhuETXJBETsg+X4mYGzfziwIYVv66Z19+C15 tVzTAmXX7vQwcTTyyHaMUlwlrSlInM55HdK6Fu7c6kA/ByzSYIIuQ2BDeCzxLFZOABku VYqmXhTL5W6D53hKY8M1agkZRYrOxzijVPSgOnE9SNWiirJAZReKbF6PhPXpzPIIh/uQ lpVgwPef4D7e+AocXSqJ22lT0Fst3GzlXYrJNntEvJRLwlkww+XGpMQgdbnU6i8WQ+F4 kNFIJRHu3DS4an4y4LtczBnE085uiA2I8N0tfT0DdyYgMXcsTHZtS+gKkkrYOSz6FrOA ENIQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j6si5682676pfa.413.2018.03.16.08.32.08; Fri, 16 Mar 2018 08:32:23 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933316AbeCPPbH (ORCPT + 99 others); Fri, 16 Mar 2018 11:31:07 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37314 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933279AbeCPPbD (ORCPT ); Fri, 16 Mar 2018 11:31:03 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 51B5F116D; Fri, 16 Mar 2018 15:30:53 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adrian Hunter , Jiri Olsa , Wang Nan , Arnaldo Carvalho de Melo Subject: [PATCH 4.9 29/86] perf tools: Fix trigger class trigger_on() Date: Fri, 16 Mar 2018 16:22:52 +0100 Message-Id: <20180316152319.379252134@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152317.167709497@linuxfoundation.org> References: <20180316152317.167709497@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Adrian Hunter commit de19e5c3c51fdb1ff20d0f61d099db902ff7494b upstream. trigger_on() means that the trigger is available but not ready, however trigger_on() was making it ready. That can segfault if the signal comes before trigger_ready(). e.g. (USR2 signal delivery not shown) $ perf record -e intel_pt//u -S sleep 1 perf: Segmentation fault Obtained 16 stack frames. /home/ahunter/bin/perf(sighandler_dump_stack+0x40) [0x4ec550] /lib/x86_64-linux-gnu/libc.so.6(+0x36caf) [0x7fa76411acaf] /home/ahunter/bin/perf(perf_evsel__disable+0x26) [0x4b9dd6] /home/ahunter/bin/perf() [0x43a45b] /lib/x86_64-linux-gnu/libc.so.6(+0x36caf) [0x7fa76411acaf] /lib/x86_64-linux-gnu/libc.so.6(__xstat64+0x15) [0x7fa7641d2cc5] /home/ahunter/bin/perf() [0x4ec6c9] /home/ahunter/bin/perf() [0x4ec73b] /home/ahunter/bin/perf() [0x4ec73b] /home/ahunter/bin/perf() [0x4ec73b] /home/ahunter/bin/perf() [0x4eca15] /home/ahunter/bin/perf(machine__create_kernel_maps+0x257) [0x4f0b77] /home/ahunter/bin/perf(perf_session__new+0xc0) [0x4f86f0] /home/ahunter/bin/perf(cmd_record+0x722) [0x43c132] /home/ahunter/bin/perf() [0x4a11ae] /home/ahunter/bin/perf(main+0x5d4) [0x427fb4] Note, for testing purposes, this is hard to hit unless you add some sleep() in builtin-record.c before record__open(). Signed-off-by: Adrian Hunter Acked-by: Jiri Olsa Cc: Wang Nan Cc: stable@vger.kernel.org Fixes: 3dcc4436fa6f ("perf tools: Introduce trigger class") Link: http://lkml.kernel.org/r/1519807144-30694-1-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/trigger.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/tools/perf/util/trigger.h +++ b/tools/perf/util/trigger.h @@ -11,7 +11,7 @@ * States and transits: * * - * OFF--(on)--> READY --(hit)--> HIT + * OFF--> ON --> READY --(hit)--> HIT * ^ | * | (ready) * | | @@ -26,8 +26,9 @@ struct trigger { volatile enum { TRIGGER_ERROR = -2, TRIGGER_OFF = -1, - TRIGGER_READY = 0, - TRIGGER_HIT = 1, + TRIGGER_ON = 0, + TRIGGER_READY = 1, + TRIGGER_HIT = 2, } state; const char *name; }; @@ -49,7 +50,7 @@ static inline bool trigger_is_error(stru static inline void trigger_on(struct trigger *t) { TRIGGER_WARN_ONCE(t, TRIGGER_OFF); - t->state = TRIGGER_READY; + t->state = TRIGGER_ON; } static inline void trigger_ready(struct trigger *t)