Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp846852ybi; Fri, 12 Jul 2019 05:37:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqwzVoFEuxTj5bcg2dUbRaoiBpQF6D2Kta/rM3AxQfXHorwo/+XHI8CAsqq6kxnHgzuG6x2k X-Received: by 2002:a17:90a:e397:: with SMTP id b23mr11560324pjz.117.1562935073972; Fri, 12 Jul 2019 05:37:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562935073; cv=none; d=google.com; s=arc-20160816; b=SilGfInLiNYf1bRu9ZDAA18RpR9n/4P2a1mQuPw4tIXej7iU6H8XGYVnJpxRm1QECg 4zj73C0BrSS4jAUMkMiqWFTpTMvXA7xs+BZePrtBBrHA4S2OtwhSp8LX+UZczDFEsoPY uwl3RnM8mQPErEe3SITKwlWewcZnSwvWbmNS6o9m4aWXLgEcq6yQ2QldRhN/4wTHZ8Im +3mx2ZIVtk/aCqtEja7ZL4rDeoprt5PfnjD5f3ImV314C49rFGtVGqCR6vVptpNOUG0Q ivkoOESaYpQE+3X7SERaz6zQFj0tCF/BqIhMWUOH6RbtOuo7IxTMYJ4QX8QP+niKTVDO MVSg== 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=uWRHPitqY+wY0Dt9Z4OycFIk/HzhVJ3wqPDUealiZKc=; b=Zb+xTzN4LEb2Y13FK4KByMu/QtrlY2G9y/o6va5f3TKw1HPepdUtGamoB2sJZUPeuz fkGQ1bqDYQVapdLPRnZ9c5iEmXYAR83GvfsKSDnf2d1B913RJwLUbkbNqzcT4eQKM/W+ BxdipuUNFHhDWUTag3/av5NxEXhOc7unuv36PxblghBj9ZLsTeGLq/DYtsYvZsLfXcI/ oDbGcygh42AmEro57Zxccn8EXLE7iTo3lDqykNPBVH52o7eTE3hbM+DOgRXbYFHRCgKz 87N3HvVHLW5U00wk5h2U0Bo9qOxsSu4JSLLS0bJD3q6qCjKeKk+Topv1SgiHZYKvufd5 SWyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CUR8qLXa; 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 t29si2700010pfq.272.2019.07.12.05.37.39; Fri, 12 Jul 2019 05:37:53 -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=CUR8qLXa; 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 S1729477AbfGLMca (ORCPT + 99 others); Fri, 12 Jul 2019 08:32:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:50420 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729474AbfGLMc0 (ORCPT ); Fri, 12 Jul 2019 08:32:26 -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 6C71821019; Fri, 12 Jul 2019 12:32:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562934745; bh=FShXrtKdc4YHViZDililVx7/5jefip73CbYnbQAZJxg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CUR8qLXawgAl5dYx6TCWYi+Wg9gD6PbwVEAbloF7b4wchJ8UN5bV9gt9xY+wMUwUE nncnBm1LFruhuxq6SLgCCEsH+mZzxEYJGq9DCHPg1KPQfVQh04V2i3CGKdLr+J+yHb TQTmiA4u6FQfcyXtzftvBE2NdbfJ3CkUVbTZyab4= 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.2 18/61] perf header: Assign proper ff->ph in perf_event__synthesize_features() Date: Fri, 12 Jul 2019 14:19:31 +0200 Message-Id: <20190712121621.620616765@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190712121620.632595223@linuxfoundation.org> References: <20190712121620.632595223@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 @@ -3602,6 +3602,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) {