lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAM9d7ch1tmkmrpcxdW4Txz20Xzt6NFx_-0m6HQzTwXAV7Opg2Q@mail.gmail.com>
Date: Wed, 21 Aug 2024 17:38:45 -0700
From: Namhyung Kim <namhyung@...nel.org>
To: kan.liang@...ux.intel.com
Cc: acme@...nel.org, irogers@...gle.com, peterz@...radead.org, 
	mingo@...nel.org, linux-kernel@...r.kernel.org, 
	linux-perf-users@...r.kernel.org
Subject: Re: [PATCH] perf hist: Don't set hpp_fmt_value for members in --no-group

Hi Kan,

On Tue, Aug 20, 2024 at 11:31 AM <kan.liang@...ux.intel.com> wrote:
>
> From: Kan Liang <kan.liang@...ux.intel.com>
>
> Perf crashes as below when applying --no-group
>
> perf record -e "{cache-misses,branches"} -b sleep 1
> perf report --stdio --no-group
> free(): invalid next size (fast)
> Aborted (core dumped)
>
> In the __hpp__fmt(), only 1 hpp_fmt_value is allocated for the current
> event when --no-group is applied. However, the current implementation
> tries to assign the hists from all members to the hpp_fmt_value, which
> exceeds the allocated memory.
>
> Fixes: 8f6071a3dce4 ("perf hist: Simplify __hpp_fmt() using hpp_fmt_data")
> Signed-off-by: Kan Liang <kan.liang@...ux.intel.com>

Acked-by: Namhyung Kim <namhyung@...nel.org>

Thanks,
Namhyung

> ---
>  tools/perf/ui/hist.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
> index 5d1f04f66a5a..e5491995adf0 100644
> --- a/tools/perf/ui/hist.c
> +++ b/tools/perf/ui/hist.c
> @@ -62,7 +62,7 @@ static int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he,
>         struct evsel *pos;
>         char *buf = hpp->buf;
>         size_t size = hpp->size;
> -       int i, nr_members = 1;
> +       int i = 0, nr_members = 1;
>         struct hpp_fmt_value *values;
>
>         if (evsel__is_group_event(evsel))
> @@ -72,16 +72,16 @@ static int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he,
>         if (values == NULL)
>                 return 0;
>
> -       i = 0;
> -       for_each_group_evsel(pos, evsel)
> -               values[i++].hists = evsel__hists(pos);
> -
> +       values[0].hists = evsel__hists(evsel);
>         values[0].val = get_field(he);
>         values[0].samples = he->stat.nr_events;
>
>         if (evsel__is_group_event(evsel)) {
>                 struct hist_entry *pair;
>
> +               for_each_group_member(pos, evsel)
> +                       values[++i].hists = evsel__hists(pos);
> +
>                 list_for_each_entry(pair, &he->pairs.head, pairs.node) {
>                         for (i = 0; i < nr_members; i++) {
>                                 if (values[i].hists != pair->hists)
> --
> 2.38.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ