Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp840076ybi; Fri, 12 Jul 2019 05:31:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqwmT+f2ouWvQb9ddL2E7e20X0GpVn22EXdsk8tJhryog1sZyszA+j4wZSSRdytLjtRNSTnS X-Received: by 2002:a17:90a:9301:: with SMTP id p1mr11544057pjo.22.1562934691149; Fri, 12 Jul 2019 05:31:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562934691; cv=none; d=google.com; s=arc-20160816; b=sCJhziBJMVPsxc2S7XkQuTUwLYjhtOCXw2uNRW6znhz497vJszbi69kXoSjHGMJKdb 4Luo9bbCSxWPOROHM/gJ/D1T7kRBtdxop3wjTG4o69FfcbKMI4ZgCGk1ANAyznmgwVXB 6lFGn3vP2DT0byB/nAW4Ix6UHqBigQ6rSlXKV//2Yw8EVnrEhukFCdVhndRBB9wDWdEe xhar/YCdvJeWADn4JVG/QmNElFWceR/8QTMzO4l6a81LG6zoC59jc2eXyMA8GnrH6zwB Ia6m+dBy0+sMNPUoXlSBviZPqB6yVCeLyII1iN1/bD9IELBP2xnp2QLfLcuggL431GHB s9CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ixLYXHTR9MOkH3xB4bY8gp++RolsIKa/wMQhrrD8h2o=; b=fyCAJco9PB6yzfr+ro5h1/CY5bByeiwe6HNZ7pJYFnZCGqKGS0Z6660SmXg72OPFBq QSp6vVFrG0jPkxJhLIzvvvX9jaU/s0RUuP5c7/ZdXeztRlTDiMqzd6TQa8AuZy8OpkNU qsTPxvIO2uVQkcARkIhAD/8WI7/qxCMAen+pIZKxU/4mv9Z9V6wjGnsKb3b1+Sn2px+Z PvOz16XLan2P8OL9pBEZQeb3A1ZREirz+Ta+X47rwRuGs2Ll+Zi0q1/7Np5KUM1HzG3C hjFcZFsq/JYy802UNHYqLIaoeVokTYW2u5qwcvwjs/PYsA7SeBNtIgRxCZP5o0os9H2y NznQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rSbSgNuF; 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 w4si7542996plz.323.2019.07.12.05.31.15; Fri, 12 Jul 2019 05:31:31 -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; dkim=pass header.i=@kernel.org header.s=default header.b=rSbSgNuF; 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 S1729023AbfGLM3l (ORCPT + 99 others); Fri, 12 Jul 2019 08:29:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:44630 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727141AbfGLM3i (ORCPT ); Fri, 12 Jul 2019 08:29:38 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E2AB921019; Fri, 12 Jul 2019 12:29:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562934577; bh=qDtEx3JBcoiN7jc5fyaWwXQltue7M5cegdGziK7DBV8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rSbSgNuFPs2L6pMu59YoFvWcqrjDNummywq1soA/cmm3SEzR77OeRZjI37i9C6y9g Nr1sJ9L7z8VpvcO1H5NVlSiXXOZH0AAw8ShPNh3DUypjBMzm9yOY7eukqYZJ5FCS0p D5UBekKy5yU2weFo5tKcieQCkPndjuSHzD0neQ7E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Carrillo Cisneros , Song Liu , Arnaldo Carvalho de Melo , Jiri Olsa , Namhyung Kim , kernel-team@fb.com Subject: [PATCH 5.1 101/138] perf header: Assign proper ff->ph in perf_event__synthesize_features() Date: Fri, 12 Jul 2019 14:19:25 +0200 Message-Id: <20190712121632.639643452@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190712121628.731888964@linuxfoundation.org> References: <20190712121628.731888964@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Song Liu commit c952b35f4b15dd1b83e952718dec3307256383ef upstream. bpf/btf write_* functions need ff->ph->env. With this missing, pipe-mode (perf record -o -) would crash like: Program terminated with signal SIGSEGV, Segmentation fault. This patch assign proper ph value to ff. Committer testing: (gdb) run record -o - Starting program: /root/bin/perf record -o - PERFILE2 Thread 1 "perf" received signal SIGSEGV, Segmentation fault. __do_write_buf (size=4, buf=0x160, ff=0x7fffffff8f80) at util/header.c:126 126 memcpy(ff->buf + ff->offset, buf, size); (gdb) bt #0 __do_write_buf (size=4, buf=0x160, ff=0x7fffffff8f80) at util/header.c:126 #1 do_write (ff=ff@entry=0x7fffffff8f80, buf=buf@entry=0x160, size=4) at util/header.c:137 #2 0x00000000004eddba in write_bpf_prog_info (ff=0x7fffffff8f80, evlist=) at util/header.c:912 #3 0x00000000004f69d7 in perf_event__synthesize_features (tool=tool@entry=0x97cc00 , session=session@entry=0x7fffe9c6d010, evlist=0x7fffe9cae010, process=process@entry=0x4435d0 ) at util/header.c:3695 #4 0x0000000000443c79 in record__synthesize (tail=tail@entry=false, rec=0x97cc00 ) at builtin-record.c:1214 #5 0x0000000000444ec9 in __cmd_record (rec=0x97cc00 , argv=, argc=0) at builtin-record.c:1435 #6 cmd_record (argc=0, argv=) at builtin-record.c:2450 #7 0x00000000004ae3e9 in run_builtin (p=p@entry=0x98e058 , argc=argc@entry=3, argv=0x7fffffffd670) at perf.c:304 #8 0x000000000042eded in handle_internal_command (argv=, argc=) at perf.c:356 #9 run_argv (argcp=, argv=) at perf.c:400 #10 main (argc=3, argv=) at perf.c:522 (gdb) After the patch the SEGSEGV is gone. Reported-by: David Carrillo Cisneros Signed-off-by: Song Liu Tested-by: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Namhyung Kim Cc: kernel-team@fb.com Cc: stable@vger.kernel.org # v5.1+ Fixes: 606f972b1361 ("perf bpf: Save bpf_prog_info information as headers to perf.data") Link: http://lkml.kernel.org/r/20190620010453.4118689-1-songliubraving@fb.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/header.c | 1 + 1 file changed, 1 insertion(+) --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -3549,6 +3549,7 @@ int perf_event__synthesize_features(stru return -ENOMEM; ff.size = sz - sz_hdr; + ff.ph = &session->header; for_each_set_bit(feat, header->adds_features, HEADER_FEAT_BITS) { if (!feat_ops[feat].synthesize) {