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: <CAP-5=fXwfckSBwMVRj_MuZ=aZkkS-bxrcWkzg1y=AZwFQGUjCQ@mail.gmail.com>
Date: Wed, 20 Mar 2024 08:40:52 -0700
From: Ian Rogers <irogers@...gle.com>
To: Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>, 
	Namhyung Kim <namhyung@...nel.org>, Mark Rutland <mark.rutland@....com>, 
	Alexander Shishkin <alexander.shishkin@...ux.intel.com>, Jiri Olsa <jolsa@...nel.org>, 
	Adrian Hunter <adrian.hunter@...el.com>, linux-perf-users@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 1/2] perf: Suggest inbuilt commands for unknown command

On Wed, Mar 20, 2024 at 8:32 AM Arnaldo Carvalho de Melo
<acme@...nel.org> wrote:
>
> On Wed, Mar 20, 2024 at 12:20:20PM -0300, Arnaldo Carvalho de Melo wrote:
> > On Wed, Mar 20, 2024 at 08:12:56AM -0700, Ian Rogers wrote:
> > > Ah, the change:
> > >
> > > -               static int done_help;
> > > +               int done_help;
> > >
> > > created an uninitialized use. Compiler warning/sanitizers? Anyway,
> > > done_help needs hoisting out of the loop and initializing to zero, or
> > > being made static again (ugh).
> >
> > ⬢[acme@...lbox perf-tools-next]$ git diff
> > diff --git a/tools/perf/perf.c b/tools/perf/perf.c
> > index c719e6ccd9e27778..f9532b20e87cbf05 100644
> > --- a/tools/perf/perf.c
> > +++ b/tools/perf/perf.c
> > @@ -459,7 +459,7 @@ static int libperf_print(enum libperf_print_level level,
> >
> >  int main(int argc, const char **argv)
> >  {
> > -       int err;
> > +       int err, done_help = 0;
> >         const char *cmd;
> >         char sbuf[STRERR_BUFSIZE];
> >
> > @@ -558,8 +558,6 @@ int main(int argc, const char **argv)
> >         pthread__block_sigwinch();
> >
> >         while (1) {
> > -               int done_help;
> > -
> >                 run_argv(&argc, &argv);
> >
> >                 if (errno != ENOENT)
> > ⬢[acme@...lbox perf-tools-next]$ perf raccord
> >   Fatal: Out of memory, realloc failed
> > ⬢[acme@...lbox perf-tools-next]$
> >
> > Then:
> >
> > diff --git a/tools/perf/perf.c b/tools/perf/perf.c
> > index c719e6ccd9e27778..54f62aa6612bc290 100644
> > --- a/tools/perf/perf.c
> > +++ b/tools/perf/perf.c
> > @@ -558,7 +558,7 @@ int main(int argc, const char **argv)
> >         pthread__block_sigwinch();
> >
> >         while (1) {
> > -               int done_help;
> > +               static int done_help;
> >
> >                 run_argv(&argc, &argv);
> >
> > ⬢[acme@...lbox perf-tools-next]$ perf raccord
> >   Fatal: Out of memory, realloc failed
> > ⬢[acme@...lbox perf-tools-next]$
>
> That main_cmds variable is uninitialized, which ends up making
> add_cmdname() to explode, are you sure this is working on your side?
>
> Further clarifying, this is without considering the second patch, I
> haven't got to it yet, from what I recall from the description it
> shouldn't matter tho.
>
> - Arnaldo
>
> ⬢[acme@...lbox perf-tools-next]$ git diff
> diff --git a/tools/perf/perf.c b/tools/perf/perf.c
> index c719e6ccd9e27778..164b3c78baff4204 100644
> --- a/tools/perf/perf.c
> +++ b/tools/perf/perf.c
> @@ -558,7 +558,7 @@ int main(int argc, const char **argv)
>         pthread__block_sigwinch();
>
>         while (1) {
> -               int done_help;
> +               static int done_help;
>
>                 run_argv(&argc, &argv);
>
> @@ -566,7 +566,7 @@ int main(int argc, const char **argv)
>                         break;
>
>                 if (!done_help) {
> -                       struct cmdnames main_cmds;
> +                       struct cmdnames main_cmds = { 0, };
>
>                         for (unsigned int i = 0; i < ARRAY_SIZE(commands); i++) {
>                                 add_cmdname(&main_cmds,
> ⬢[acme@...lbox perf-tools-next]$ perf raccord
> perf: 'raccord' is not a perf-command. See 'perf --help'.
> ⬢[acme@...lbox perf-tools-next]$

Perhaps change the 'a' to an 'e', the 2nd patch just improves the
weights on removing characters. For me:

```
$ /tmp/perf/perf raccord
perf: 'raccord' is not a perf-command. See 'perf --help'.

Did you mean this?
       record
```

For a memory sanitizer build with the 2 patches and the 2 line changes
I sent before. Fwiw, I'm trying to get memory sanitizer to test "perf
test" but running into an issue with scandirat not having an msan
interceptor.

Thanks,
Ian

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ