[lkml]   [2019]   [Jul]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[tip:perf/core] perf header: Assign proper ff->ph in perf_event__synthesize_features()
Commit-ID:  c952b35f4b15dd1b83e952718dec3307256383ef
Author: Song Liu <>
AuthorDate: Wed, 19 Jun 2019 18:04:53 -0700
Committer: Arnaldo Carvalho de Melo <>
CommitDate: Sat, 6 Jul 2019 14:29:04 -0300

perf header: Assign proper ff->ph in perf_event__synthesize_features()

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 -
<SNIP start of headers>
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=<optimized out>) at util/header.c:912
#3 0x00000000004f69d7 in perf_event__synthesize_features (tool=tool@entry=0x97cc00 <record>, session=session@entry=0x7fffe9c6d010,
evlist=0x7fffe9cae010, process=process@entry=0x4435d0 <process_synthesized_event>) at util/header.c:3695
#4 0x0000000000443c79 in record__synthesize (tail=tail@entry=false, rec=0x97cc00 <record>) at builtin-record.c:1214
#5 0x0000000000444ec9 in __cmd_record (rec=0x97cc00 <record>, argv=<optimized out>, argc=0) at builtin-record.c:1435
#6 cmd_record (argc=0, argv=<optimized out>) at builtin-record.c:2450
#7 0x00000000004ae3e9 in run_builtin (p=p@entry=0x98e058 <commands+216>, argc=argc@entry=3, argv=0x7fffffffd670) at perf.c:304
#8 0x000000000042eded in handle_internal_command (argv=<optimized out>, argc=<optimized out>) at perf.c:356
#9 run_argv (argcp=<optimized out>, argv=<optimized out>) at perf.c:400
#10 main (argc=3, argv=<optimized out>) at perf.c:522

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: # v5.1+
Fixes: 606f972b1361 ("perf bpf: Save bpf_prog_info information as headers to")
Signed-off-by: Arnaldo Carvalho de Melo <>
tools/perf/util/header.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 847ae51a524b..fb0aa661644b 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -3602,6 +3602,7 @@ int perf_event__synthesize_features(struct perf_tool *tool,
return -ENOMEM;

ff.size = sz - sz_hdr;
+ = &session->header;

for_each_set_bit(feat, header->adds_features, HEADER_FEAT_BITS) {
if (!feat_ops[feat].synthesize) {
 \ /
  Last update: 2019-07-09 13:30    [W:0.038 / U:3.968 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site