All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf: assign proper ff->ph in perf_event__synthesize_features()
@ 2019-06-20  1:04 Song Liu
  2019-07-06 17:17 ` Arnaldo Carvalho de Melo
  2019-07-09 11:29 ` [tip:perf/core] perf header: Assign " tip-bot for Song Liu
  0 siblings, 2 replies; 3+ messages in thread
From: Song Liu @ 2019-06-20  1:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: kernel-team, acme, davidca, jolsa, namhyung, Song Liu, stable

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.

Cc: stable@vger.kernel.org #v5.1+
Fixes: 606f972b1361 ("perf bpf: Save bpf_prog_info information as headers to perf.data")
Reported-by: David Carrillo Cisneros <davidca@fb.com>
Signed-off-by: Song Liu <songliubraving@fb.com>
---
 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 06ddb6618ef3..5f1aa0284e1b 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -3684,6 +3684,7 @@ int perf_event__synthesize_features(struct perf_tool *tool,
 		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) {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf: assign proper ff->ph in perf_event__synthesize_features()
  2019-06-20  1:04 [PATCH] perf: assign proper ff->ph in perf_event__synthesize_features() Song Liu
@ 2019-07-06 17:17 ` Arnaldo Carvalho de Melo
  2019-07-09 11:29 ` [tip:perf/core] perf header: Assign " tip-bot for Song Liu
  1 sibling, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2019-07-06 17:17 UTC (permalink / raw)
  To: Song Liu; +Cc: linux-kernel, kernel-team, davidca, jolsa, namhyung, stable

Em Wed, Jun 19, 2019 at 06:04:53PM -0700, Song Liu escreveu:
> 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.

Thanks, applied.

- Arnaldo
 
> Cc: stable@vger.kernel.org #v5.1+
> Fixes: 606f972b1361 ("perf bpf: Save bpf_prog_info information as headers to perf.data")
> Reported-by: David Carrillo Cisneros <davidca@fb.com>
> Signed-off-by: Song Liu <songliubraving@fb.com>
> ---
>  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 06ddb6618ef3..5f1aa0284e1b 100644
> --- a/tools/perf/util/header.c
> +++ b/tools/perf/util/header.c
> @@ -3684,6 +3684,7 @@ int perf_event__synthesize_features(struct perf_tool *tool,
>  		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) {
> -- 
> 2.17.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:perf/core] perf header: Assign proper ff->ph in perf_event__synthesize_features()
  2019-06-20  1:04 [PATCH] perf: assign proper ff->ph in perf_event__synthesize_features() Song Liu
  2019-07-06 17:17 ` Arnaldo Carvalho de Melo
@ 2019-07-09 11:29 ` tip-bot for Song Liu
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Song Liu @ 2019-07-09 11:29 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: songliubraving, hpa, davidca, jolsa, linux-kernel, namhyung, tglx,
	acme, mingo

Commit-ID:  c952b35f4b15dd1b83e952718dec3307256383ef
Gitweb:     https://git.kernel.org/tip/c952b35f4b15dd1b83e952718dec3307256383ef
Author:     Song Liu <songliubraving@fb.com>
AuthorDate: Wed, 19 Jun 2019 18:04:53 -0700
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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 -
  PERFILE2
  <SNIP start of perf.data 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
  (gdb)

After the patch the SEGSEGV is gone.

Reported-by: David Carrillo Cisneros <davidca@fb.com>
Signed-off-by: Song Liu <songliubraving@fb.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
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 <acme@redhat.com>
---
 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;
+	ff.ph = &session->header;
 
 	for_each_set_bit(feat, header->adds_features, HEADER_FEAT_BITS) {
 		if (!feat_ops[feat].synthesize) {

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-07-09 11:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-20  1:04 [PATCH] perf: assign proper ff->ph in perf_event__synthesize_features() Song Liu
2019-07-06 17:17 ` Arnaldo Carvalho de Melo
2019-07-09 11:29 ` [tip:perf/core] perf header: Assign " tip-bot for Song Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.