From: Jiri Olsa <jolsa@redhat.com>
To: "Du, Changbin" <changbin.du@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>, Jiri Olsa <jolsa@kernel.org>,
peterz@infradead.org, mingo@redhat.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] perf: fix double free at function perf_hpp__reset_output_field
Date: Tue, 11 Apr 2017 12:05:31 +0200 [thread overview]
Message-ID: <20170411100531.GC21238@krava> (raw)
In-Reply-To: <20170411082550.GA5894@intel.com>
On Tue, Apr 11, 2017 at 04:25:50PM +0800, Du, Changbin wrote:
> > > (gdb) print fmt.sort_list
> > > $5 = {next = 0x9727d0 <perf_hpp_list+16>, prev = 0x9727d0 <perf_hpp_list+16>}
> > >
> > > In this case, the fmt is linked in sort_list, but not in list. So crash
> > > at the list_del_init(&fmt->list) of second loop.
> >
> > so the only place I can see the POISON could get there
> > is in perf_hpp__column_unregister.. can't we just get
> > rid of it like below
> >
> > jirka
> >
> >
> > ---
> > diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
> > index 5d632dca672a..7577effbf746 100644
> > --- a/tools/perf/ui/hist.c
> > +++ b/tools/perf/ui/hist.c
> > @@ -529,7 +529,7 @@ void perf_hpp_list__prepend_sort_field(struct perf_hpp_list *list,
> >
> > void perf_hpp__column_unregister(struct perf_hpp_fmt *format)
> > {
> > - list_del(&format->list);
> > + list_del_init(&format->list);
> > }
> >
> yes, this is an option. But for safety, I sugguest do not rely on list_del_init.
> No rule rather than create one.
>
> But anyway, both are ok for me. What's your options?
hum, also I dont think we need to touch that bit at all
if we are going to remove it right away.. how about the
change below?
jirka
---
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 5d632dca672a..0ee7db43dd7d 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -613,15 +613,15 @@ void perf_hpp__reset_output_field(struct perf_hpp_list *list)
/* reset output fields */
perf_hpp_list__for_each_format_safe(list, fmt, tmp) {
- list_del_init(&fmt->list);
- list_del_init(&fmt->sort_list);
+ list_del(&fmt->list);
+ /* Remove the fmt from next loop processing. */
+ list_del(&fmt->sort_list);
fmt_free(fmt);
}
/* reset sort keys */
perf_hpp_list__for_each_sort_list_safe(list, fmt, tmp) {
- list_del_init(&fmt->list);
- list_del_init(&fmt->sort_list);
+ list_del(&fmt->sort_list);
fmt_free(fmt);
}
}
next prev parent reply other threads:[~2017-04-11 10:06 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-15 2:16 [PATCH] perf: double free at function perf_hpp__reset_output_field changbin.du
2017-03-27 6:22 ` [PATCH v2] perf: fix " changbin.du
2017-04-04 15:19 ` Arnaldo Carvalho de Melo
2017-04-04 15:34 ` Namhyung Kim
2017-04-04 15:51 ` Arnaldo Carvalho de Melo
2017-04-05 2:44 ` Du, Changbin
2017-04-09 17:05 ` Jiri Olsa
2017-04-10 2:13 ` Du, Changbin
2017-04-10 8:39 ` Jiri Olsa
2017-04-10 10:21 ` Du, Changbin
2017-04-10 11:33 ` Jiri Olsa
2017-04-11 3:06 ` Du, Changbin
2017-04-11 7:35 ` Jiri Olsa
2017-04-11 8:25 ` Du, Changbin
2017-04-11 10:05 ` Jiri Olsa [this message]
2017-04-11 10:13 ` Du, Changbin
2017-04-11 10:32 ` Jiri Olsa
2017-04-12 1:48 ` Du, Changbin
2017-05-31 7:05 ` Du, Changbin
2017-05-31 7:19 ` Jiri Olsa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170411100531.GC21238@krava \
--to=jolsa@redhat.com \
--cc=acme@kernel.org \
--cc=changbin.du@intel.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox