* [PATCH perf/urgent] perf tools: Fix crash in ordered_events__free
@ 2019-01-17 11:30 Jiri Olsa
2019-01-17 14:03 ` Song Liu
2019-01-22 11:33 ` [tip:perf/urgent] perf ordered_events: " tip-bot for Jiri Olsa
0 siblings, 2 replies; 4+ messages in thread
From: Jiri Olsa @ 2019-01-17 11:30 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Stephane Eranian, lkml, Ingo Molnar, Namhyung Kim,
Alexander Shishkin, Peter Zijlstra
Song Liu reported crash in perf record:
> #0 0x0000000000500055 in ordered_events(float, long double,...)(...) ()
> #1 0x0000000000500196 in ordered_events.reinit ()
> #2 0x00000000004fe413 in perf_session.process_events ()
> #3 0x0000000000440431 in cmd_record ()
> #4 0x00000000004a439f in run_builtin ()
> #5 0x000000000042b3e5 in main ()"
This can happen when we get out of the buffers during
event processing. The subsequent ordered_events__free
assumes the oe->buffer != NULL and crashes. Adding
the check to prevent that.
Cc: Stephane Eranian <eranian@google.com>
Fixes: d5ceb62b3654 ("perf ordered_events: Add 'struct ordered_events_buffer' layer")
Reported-by: Song Liu <liu.song.a23@gmail.com>
Link: http://lkml.kernel.org/n/tip-914bml5kabz2m9mbywd7el9l@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/ordered-events.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/ordered-events.c b/tools/perf/util/ordered-events.c
index 897589507d97..ea523d3b248f 100644
--- a/tools/perf/util/ordered-events.c
+++ b/tools/perf/util/ordered-events.c
@@ -391,8 +391,10 @@ void ordered_events__free(struct ordered_events *oe)
* Current buffer might not have all the events allocated
* yet, we need to free only allocated ones ...
*/
- list_del(&oe->buffer->list);
- ordered_events_buffer__free(oe->buffer, oe->buffer_idx, oe);
+ if (oe->buffer) {
+ list_del(&oe->buffer->list);
+ ordered_events_buffer__free(oe->buffer, oe->buffer_idx, oe);
+ }
/* ... and continue with the rest */
list_for_each_entry_safe(buffer, tmp, &oe->to_free, list) {
--
2.17.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH perf/urgent] perf tools: Fix crash in ordered_events__free
2019-01-17 11:30 [PATCH perf/urgent] perf tools: Fix crash in ordered_events__free Jiri Olsa
@ 2019-01-17 14:03 ` Song Liu
2019-01-17 14:06 ` Arnaldo Carvalho de Melo
2019-01-22 11:33 ` [tip:perf/urgent] perf ordered_events: " tip-bot for Jiri Olsa
1 sibling, 1 reply; 4+ messages in thread
From: Song Liu @ 2019-01-17 14:03 UTC (permalink / raw)
To: Jiri Olsa
Cc: Arnaldo Carvalho de Melo, Stephane Eranian, lkml, Ingo Molnar,
Namhyung Kim, Alexander Shishkin, Peter Zijlstra
On Thu, Jan 17, 2019 at 3:54 AM Jiri Olsa <jolsa@kernel.org> wrote:
>
> Song Liu reported crash in perf record:
>
> > #0 0x0000000000500055 in ordered_events(float, long double,...)(...) ()
> > #1 0x0000000000500196 in ordered_events.reinit ()
> > #2 0x00000000004fe413 in perf_session.process_events ()
> > #3 0x0000000000440431 in cmd_record ()
> > #4 0x00000000004a439f in run_builtin ()
> > #5 0x000000000042b3e5 in main ()"
>
> This can happen when we get out of the buffers during
> event processing. The subsequent ordered_events__free
> assumes the oe->buffer != NULL and crashes. Adding
> the check to prevent that.
>
> Cc: Stephane Eranian <eranian@google.com>
> Fixes: d5ceb62b3654 ("perf ordered_events: Add 'struct ordered_events_buffer' layer")
> Reported-by: Song Liu <liu.song.a23@gmail.com>
> Link: http://lkml.kernel.org/n/tip-914bml5kabz2m9mbywd7el9l@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Reviewed-and-tested-by: Song Liu <songliubraving@fb.com>
Thanks again for the fix!
Song
> ---
> tools/perf/util/ordered-events.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/ordered-events.c b/tools/perf/util/ordered-events.c
> index 897589507d97..ea523d3b248f 100644
> --- a/tools/perf/util/ordered-events.c
> +++ b/tools/perf/util/ordered-events.c
> @@ -391,8 +391,10 @@ void ordered_events__free(struct ordered_events *oe)
> * Current buffer might not have all the events allocated
> * yet, we need to free only allocated ones ...
> */
> - list_del(&oe->buffer->list);
> - ordered_events_buffer__free(oe->buffer, oe->buffer_idx, oe);
> + if (oe->buffer) {
> + list_del(&oe->buffer->list);
> + ordered_events_buffer__free(oe->buffer, oe->buffer_idx, oe);
> + }
>
> /* ... and continue with the rest */
> list_for_each_entry_safe(buffer, tmp, &oe->to_free, list) {
> --
> 2.17.2
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH perf/urgent] perf tools: Fix crash in ordered_events__free
2019-01-17 14:03 ` Song Liu
@ 2019-01-17 14:06 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2019-01-17 14:06 UTC (permalink / raw)
To: Song Liu
Cc: Jiri Olsa, Stephane Eranian, lkml, Ingo Molnar, Namhyung Kim,
Alexander Shishkin, Peter Zijlstra
Em Thu, Jan 17, 2019 at 06:03:04AM -0800, Song Liu escreveu:
> On Thu, Jan 17, 2019 at 3:54 AM Jiri Olsa <jolsa@kernel.org> wrote:
> >
> > Song Liu reported crash in perf record:
> >
> > > #0 0x0000000000500055 in ordered_events(float, long double,...)(...) ()
> > > #1 0x0000000000500196 in ordered_events.reinit ()
> > > #2 0x00000000004fe413 in perf_session.process_events ()
> > > #3 0x0000000000440431 in cmd_record ()
> > > #4 0x00000000004a439f in run_builtin ()
> > > #5 0x000000000042b3e5 in main ()"
> >
> > This can happen when we get out of the buffers during
> > event processing. The subsequent ordered_events__free
> > assumes the oe->buffer != NULL and crashes. Adding
> > the check to prevent that.
> >
> > Cc: Stephane Eranian <eranian@google.com>
> > Fixes: d5ceb62b3654 ("perf ordered_events: Add 'struct ordered_events_buffer' layer")
> > Reported-by: Song Liu <liu.song.a23@gmail.com>
> > Link: http://lkml.kernel.org/n/tip-914bml5kabz2m9mbywd7el9l@git.kernel.org
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
>
> Reviewed-and-tested-by: Song Liu <songliubraving@fb.com>
>
> Thanks again for the fix!
Thanks, applied to acme/perf/urgent,
- Arnaldo
^ permalink raw reply [flat|nested] 4+ messages in thread
* [tip:perf/urgent] perf ordered_events: Fix crash in ordered_events__free
2019-01-17 11:30 [PATCH perf/urgent] perf tools: Fix crash in ordered_events__free Jiri Olsa
2019-01-17 14:03 ` Song Liu
@ 2019-01-22 11:33 ` tip-bot for Jiri Olsa
1 sibling, 0 replies; 4+ messages in thread
From: tip-bot for Jiri Olsa @ 2019-01-22 11:33 UTC (permalink / raw)
To: linux-tip-commits
Cc: hpa, mingo, peterz, eranian, jolsa, namhyung, alexander.shishkin,
linux-kernel, acme, tglx, liu.song.a23
Commit-ID: 99d86c8b88393e29cf07c020585f2c8afbcdd97d
Gitweb: https://git.kernel.org/tip/99d86c8b88393e29cf07c020585f2c8afbcdd97d
Author: Jiri Olsa <jolsa@kernel.org>
AuthorDate: Thu, 17 Jan 2019 12:30:17 +0100
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 17 Jan 2019 11:07:00 -0300
perf ordered_events: Fix crash in ordered_events__free
Song Liu reported crash in 'perf record':
> #0 0x0000000000500055 in ordered_events(float, long double,...)(...) ()
> #1 0x0000000000500196 in ordered_events.reinit ()
> #2 0x00000000004fe413 in perf_session.process_events ()
> #3 0x0000000000440431 in cmd_record ()
> #4 0x00000000004a439f in run_builtin ()
> #5 0x000000000042b3e5 in main ()"
This can happen when we get out of buffers during event processing.
The subsequent ordered_events__free() call assumes oe->buffer != NULL
and crashes. Add a check to prevent that.
Reported-by: Song Liu <liu.song.a23@gmail.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Reviewed-by: Song Liu <liu.song.a23@gmail.com>
Tested-by: Song Liu <liu.song.a23@gmail.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/20190117113017.12977-1-jolsa@kernel.org
Fixes: d5ceb62b3654 ("perf ordered_events: Add 'struct ordered_events_buffer' layer")
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/ordered-events.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/ordered-events.c b/tools/perf/util/ordered-events.c
index 897589507d97..ea523d3b248f 100644
--- a/tools/perf/util/ordered-events.c
+++ b/tools/perf/util/ordered-events.c
@@ -391,8 +391,10 @@ void ordered_events__free(struct ordered_events *oe)
* Current buffer might not have all the events allocated
* yet, we need to free only allocated ones ...
*/
- list_del(&oe->buffer->list);
- ordered_events_buffer__free(oe->buffer, oe->buffer_idx, oe);
+ if (oe->buffer) {
+ list_del(&oe->buffer->list);
+ ordered_events_buffer__free(oe->buffer, oe->buffer_idx, oe);
+ }
/* ... and continue with the rest */
list_for_each_entry_safe(buffer, tmp, &oe->to_free, list) {
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-01-22 11:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-17 11:30 [PATCH perf/urgent] perf tools: Fix crash in ordered_events__free Jiri Olsa
2019-01-17 14:03 ` Song Liu
2019-01-17 14:06 ` Arnaldo Carvalho de Melo
2019-01-22 11:33 ` [tip:perf/urgent] perf ordered_events: " tip-bot for Jiri Olsa
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).