Received: by 10.213.65.68 with SMTP id h4csp432918imn; Tue, 13 Mar 2018 08:54:36 -0700 (PDT) X-Google-Smtp-Source: AG47ELvQm9Ed3VoBf1p7KA8bO/Rliv+vSr5eRnTzAc5vx/JrwbZBiFbrrz+T06rDbmyMg4IRGbiv X-Received: by 2002:a17:902:604f:: with SMTP id a15-v6mr834988plt.184.1520956476050; Tue, 13 Mar 2018 08:54:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520956476; cv=none; d=google.com; s=arc-20160816; b=ygXWq4r31gybJzBZQKlDFMOQ2tyhSdvDJvxNXPnV0FO64+By9ts+LIJa+VYpMgdeJG fdlvXRVs9Q3jKBfwBajptJVTS0QE/+HVAgHnweUPhSiG0RJbeV55/Kn4PRvmArDprDJG 8PaxQ9EtXT333O+xg1Sp/UtowbKgTtGK5Ozl7wkrAoDnz+tsrynbR+hcw8vMaxoPKuen PqRMiV72wq/0EM/Z99YQn7VSridxBnovV6ZUL2UuSnp2DtHOJmFocfeUdyVfNbfLef+m uh75pMq8O2dYh6Ppzx6djYZcNnap66la6hzzVsW9oxDwY9Jjj6E8UkjWoNhQIuxnZUtD wqcQ== 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=1RQePxLzC+saqqz5nK+zSNS4b0Jd+n5/eilU/2q+FsA=; b=AY14xS+NYYolYhyooLtVueq+llxoj3lfYvgeBVOSF+m1a8/kgY2YZyUu+AF7INLrza sDQbBzn3thZiwVBItTPMyHdD6CbuOhQkPGJyRjpY2cmMDtqZSuleFPN6RVmBQ/k1eXyZ aq7ytOBzfV0HlMSXBwjhUYWuKH6q6Kgipq5j4BrSaCAKd4jHpyljalPkHgWoWt5E8067 Wr6HQzPcrTjp6mZQkSMnKLCbXRBpTjYbS/EoE8NasOp7G23C4mguWCiRRAnu9k2jDvn4 u3LmwfE6wjkpc48q7B+/lWDLcp51i1oj7FbBFx1HlA2tkoB+xkuSnBOSZBN+e0l9gbZA zWsA== 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 s71si317420pfj.396.2018.03.13.08.54.20; Tue, 13 Mar 2018 08:54:36 -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 S934788AbeCMPjq (ORCPT + 99 others); Tue, 13 Mar 2018 11:39:46 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:35412 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934132AbeCMPjm (ORCPT ); Tue, 13 Mar 2018 11:39:42 -0400 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 539DDFBC; Tue, 13 Mar 2018 15:39:41 +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.14 099/140] perf tools: Fix trigger class trigger_on() Date: Tue, 13 Mar 2018 16:25:02 +0100 Message-Id: <20180313152504.810772910@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180313152458.201155692@linuxfoundation.org> References: <20180313152458.201155692@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.14-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 @@ -12,7 +12,7 @@ * States and transits: * * - * OFF--(on)--> READY --(hit)--> HIT + * OFF--> ON --> READY --(hit)--> HIT * ^ | * | (ready) * | | @@ -27,8 +27,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; }; @@ -50,7 +51,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)