[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CO6PR11MB56356C8B9E938EBF39524C1EEE2A2@CO6PR11MB5635.namprd11.prod.outlook.com>
Date: Wed, 13 Mar 2024 00:27:45 +0000
From: "Wang, Weilin" <weilin.wang@...el.com>
To: Andi Kleen <ak@...ux.intel.com>
CC: Namhyung Kim <namhyung@...nel.org>, Ian Rogers <irogers@...gle.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>, Peter Zijlstra
<peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>, Alexander Shishkin
<alexander.shishkin@...ux.intel.com>, Jiri Olsa <jolsa@...nel.org>, "Hunter,
Adrian" <adrian.hunter@...el.com>, Kan Liang <kan.liang@...ux.intel.com>,
"linux-perf-users@...r.kernel.org" <linux-perf-users@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>, "Taylor,
Perry" <perry.taylor@...el.com>, "Alt, Samantha" <samantha.alt@...el.com>,
"Biggers, Caleb" <caleb.biggers@...el.com>
Subject: RE: [RFC PATCH v4 1/6] perf stat: Parse and find tpebs events when
parsing metrics to prepare for perf record sampling
> -----Original Message-----
> From: Andi Kleen <ak@...ux.intel.com>
> Sent: Tuesday, March 12, 2024 4:58 PM
> To: Wang, Weilin <weilin.wang@...el.com>
> Cc: Namhyung Kim <namhyung@...nel.org>; Ian Rogers
> <irogers@...gle.com>; Arnaldo Carvalho de Melo <acme@...nel.org>; Peter
> Zijlstra <peterz@...radead.org>; Ingo Molnar <mingo@...hat.com>;
> Alexander Shishkin <alexander.shishkin@...ux.intel.com>; Jiri Olsa
> <jolsa@...nel.org>; Hunter, Adrian <adrian.hunter@...el.com>; Kan Liang
> <kan.liang@...ux.intel.com>; linux-perf-users@...r.kernel.org; linux-
> kernel@...r.kernel.org; Taylor, Perry <perry.taylor@...el.com>; Alt, Samantha
> <samantha.alt@...el.com>; Biggers, Caleb <caleb.biggers@...el.com>
> Subject: Re: [RFC PATCH v4 1/6] perf stat: Parse and find tpebs events when
> parsing metrics to prepare for perf record sampling
>
> weilin.wang@...el.com writes:
> > +
> > + new_event->tpebs_name = strdup(id);
> > + *p = '\0';
> > + name = malloc(strlen(id) + 2);
> > + if (!name)
> > + return -ENOMEM;
> > +
> > + at = strchr(id, '@');
> > + if (at != NULL) {
> > + *at = '/';
> > + at = strchr(id, '@');
> > + *at = '/';
> > + strcpy(name, id);
> > + strcat(name, "p");
> > + } else {
> > + strcpy(name, id);
> > + strcat(name, ":p");
>
>
> This seems like a buffer overflow because :p is 3 bytes including 0,
> but you only allocate + 2.
> You should really use safe string primitives, then you would have
> noticed the truncation.
>
I will double check and update this part.
Thanks,
Weilin
> -Andi
Powered by blists - more mailing lists