Received: by 10.213.65.68 with SMTP id h4csp465699imn; Tue, 13 Mar 2018 09:56:06 -0700 (PDT) X-Google-Smtp-Source: AG47ELtIB8mtfp0/9z1mxliHcQniId3NnH081TNEXovLdDnhGbGGZBp7FeVjW1uDHuHF3agFYTBt X-Received: by 10.98.59.218 with SMTP id w87mr1263466pfj.37.1520960166128; Tue, 13 Mar 2018 09:56:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520960166; cv=none; d=google.com; s=arc-20160816; b=UXfIkHuIvOFByYN0wDXYZFv2zuiRNhrQTYCSPQy282+Bj6IJcNrtqO08lCq/Hda4fz 4R2RR06sE669PCBesLid194u0MFpTxXpcakyFQCylYTU4xA7ttbL4IvT9LSyetYkmK2V ZT/3pYY7FnUOd6q8S6AHl+ViQjfhNltilibEPN0TdfL+heD8jCpKW+foGVN7K////lrk 4aA3PzveXVF6GnwPmOWGFwOpxmrzNDk5cWYzrHHxBN1QnoSchbtWdTcgZ55BdL8G7+qX 6U+xVFxXONndKZn9hPXVE+kuEPbyo3hNtvi4cm7WMgRfEK9fcwd7W6h+C9BHl3OYDh/I dy4w== 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=M7wcaG2OZIU+sYZxUb5RIUv0sVul3N2fLQhp4bHJXK0=; b=dAPr3hZ89xD2ztHhAviCT7UljjpZKNuWxCdKW3BHdF6y3mZQV0itKJGz4V9+YCRbhf eQPrDhHnSGr8kIB0t+adULc6RGKOFL+949oQFiYgF49AYielpnRuIAbADCSYD9pplzGy kpxpmE/b+H92C3ZDwO/HHJSiCs7S7V1jbdZtMwIRk5tgYu6+XJG2EfACtdQkRkllmrT1 30T8N9GjWu0wTT5C/uguOQCUsbGNYQX8ZerA34Hgu0Jh4+9FOWuPhDu9qZihqx9367QS BM+t+zdmZ8hKAQYUNIE1E9v83NMdW+iZ75F6bcjpyyn//2yCAQBykvr8BEtJKFxTanib uD5Q== 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 o63si366261pfg.347.2018.03.13.09.55.51; Tue, 13 Mar 2018 09:56:06 -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 S1752571AbeCMPad (ORCPT + 99 others); Tue, 13 Mar 2018 11:30:33 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58838 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752489AbeCMPaa (ORCPT ); Tue, 13 Mar 2018 11:30:30 -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 0C42E504; Tue, 13 Mar 2018 15:30:29 +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.15 064/146] perf tools: Fix trigger class trigger_on() Date: Tue, 13 Mar 2018 16:23:51 +0100 Message-Id: <20180313152325.626383901@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180313152320.439085687@linuxfoundation.org> References: <20180313152320.439085687@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.15-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)