Received: by 10.192.165.148 with SMTP id m20csp573725imm; Wed, 25 Apr 2018 04:30:49 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpPden8ZPBLm4QlXrZHqacwlUpTS6rlRyMVRYHRzVUB5ivc7iLHFC21d9TAHRYi32qwa090 X-Received: by 2002:a17:902:bd0a:: with SMTP id p10-v6mr210558pls.69.1524655849654; Wed, 25 Apr 2018 04:30:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524655849; cv=none; d=google.com; s=arc-20160816; b=tyXjCn4G4kJQ9GJEUKfpyUVPeQ9L8zZ9uy7WKnLnvP5rQV1U3CIJxqtJB2px0Je7as /DemandHUJH6ElwHY59YeROsiKTlhUFS9ls3bYgFNmgfgzDQ+x3ow+mjvUf7Y+zCVlKa OXpD4EmyzC6KPvsTxusrmlVICWXUbHfO13vAOYxvUVxShbrvosvED27SqymlNiUQi6im /KDfCKg9uXR+1Veepl52RVCbraJZpE0XgsLTh7YSKVbFe8Ltbij4mXSUHCVaMS11TqHE zTRtUBFS3xmrfe7AUAHGwzdgZLMXrVDUklbUEmTXugyokT4PWw6nJLsW+1c2ILqiBK5T RZrA== 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=SlmbVhkViWkKfX3GuKBGEm8hLAIowRHpefiiKLtKOwk=; b=wfpypiClaPU5QrVa6gHHisAC+mub29RRV9W1DXAX8b5wlpVa7yxCSZm9AsXpzEue5o b2kHLMDpDfIQsY4jWbhQVNgZ3hhgE7tS34T2+3EREu275Wdd5VXwJkC+INAAg/Lhn5Op k40BYASpMo/onun7DKgeZInWLS/ao644BDPzecEg+zddZytQ3rzaSYfAyqlqF3URjfM/ kNBxG775+xj5rtITYci6S3BNnOsLDSAW8/cmUUD/NzxM7Nj0tuUdAmxoZC3IsaXFjBGN /Ew0OhKElny7qsi0bQcd9f3PvbG99HEZgwSjKerMp8UE0Ay4yno6x2FOmsPr5kQhmW/E 1wpQ== 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 k13si13568219pgr.124.2018.04.25.04.30.35; Wed, 25 Apr 2018 04:30:49 -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 S1753492AbeDYL2l (ORCPT + 99 others); Wed, 25 Apr 2018 07:28:41 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:51410 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751571AbeDYKi0 (ORCPT ); Wed, 25 Apr 2018 06:38:26 -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 9C943272; Wed, 25 Apr 2018 10:38:25 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adrian Hunter , David Ahern , Hendrick Brueckner , Jiri Olsa , Namhyung Kim , Thomas Richter , Wang Nan , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 4.14 040/183] perf callchain: Fix attr.sample_max_stack setting Date: Wed, 25 Apr 2018 12:34:20 +0200 Message-Id: <20180425103244.184508826@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425103242.532713678@linuxfoundation.org> References: <20180425103242.532713678@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: Arnaldo Carvalho de Melo [ Upstream commit 249d98e567e25dd03e015e2d31e1b7b9648f34df ] When setting the "dwarf" unwinder for a specific event and not specifying the max-stack, the attr.sample_max_stack ended up using an uninitialized callchain_param.max_stack, fix it by using designated initializers for that callchain_param variable, zeroing all non explicitely initialized struct members. Here is what happened: # perf trace -vv --no-syscalls --max-stack 4 -e probe_libc:inet_pton/call-graph=dwarf/ ping -6 -c 1 ::1 callchain: type DWARF callchain: stack dump size 8192 perf_event_attr: type 2 size 112 config 0x730 { sample_period, sample_freq } 1 sample_type IP|TID|TIME|ADDR|CALLCHAIN|CPU|PERIOD|RAW|REGS_USER|STACK_USER|DATA_SRC exclude_callchain_user 1 { wakeup_events, wakeup_watermark } 1 sample_regs_user 0xff0fff sample_stack_user 8192 sample_max_stack 50656 sys_perf_event_open failed, error -75 Value too large for defined data type # perf trace -vv --no-syscalls --max-stack 4 -e probe_libc:inet_pton/call-graph=dwarf/ ping -6 -c 1 ::1 callchain: type DWARF callchain: stack dump size 8192 perf_event_attr: type 2 size 112 config 0x730 sample_type IP|TID|TIME|ADDR|CALLCHAIN|CPU|PERIOD|RAW|REGS_USER|STACK_USER|DATA_SRC exclude_callchain_user 1 sample_regs_user 0xff0fff sample_stack_user 8192 sample_max_stack 30448 sys_perf_event_open failed, error -75 Value too large for defined data type # Now the attr.sample_max_stack is set to zero and the above works as expected: # perf trace --no-syscalls --max-stack 4 -e probe_libc:inet_pton/call-graph=dwarf/ ping -6 -c 1 ::1 PING ::1(::1) 56 data bytes 64 bytes from ::1: icmp_seq=1 ttl=64 time=0.072 ms --- ::1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.072/0.072/0.072/0.000 ms 0.000 probe_libc:inet_pton:(7feb7a998350)) __inet_pton (inlined) gaih_inet.constprop.7 (/usr/lib64/libc-2.26.so) __GI_getaddrinfo (inlined) [0xffffaa39b6108f3f] (/usr/bin/ping) # Cc: Adrian Hunter Cc: David Ahern Cc: Hendrick Brueckner Cc: Jiri Olsa Cc: Namhyung Kim Cc: Thomas Richter Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-is9tramondqa9jlxxsgcm9iz@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/evsel.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -722,14 +722,14 @@ static void apply_config_terms(struct pe struct perf_evsel_config_term *term; struct list_head *config_terms = &evsel->config_terms; struct perf_event_attr *attr = &evsel->attr; - struct callchain_param param; + /* callgraph default */ + struct callchain_param param = { + .record_mode = callchain_param.record_mode, + }; u32 dump_size = 0; int max_stack = 0; const char *callgraph_buf = NULL; - /* callgraph default */ - param.record_mode = callchain_param.record_mode; - list_for_each_entry(term, config_terms, list) { switch (term->type) { case PERF_EVSEL__CONFIG_TERM_PERIOD: