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] [day] [month] [year] [list]
Date: Fri, 16 Feb 2024 14:53:44 -0800
From: Ian Rogers <irogers@...gle.com>
To: Namhyung Kim <namhyung@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>, 
	Arnaldo Carvalho de Melo <acme@...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>, Nathan Chancellor <nathan@...nel.org>, 
	Nick Desaulniers <ndesaulniers@...gle.com>, Bill Wendling <morbo@...gle.com>, 
	Justin Stitt <justinstitt@...gle.com>, James Clark <james.clark@....com>, 
	Athira Jajeev <atrajeev@...ux.vnet.ibm.com>, Kan Liang <kan.liang@...ux.intel.com>, 
	Yang Jihong <yangjihong1@...wei.com>, linux-kernel@...r.kernel.org, 
	linux-perf-users@...r.kernel.org, llvm@...ts.linux.dev
Subject: Re: [PATCH v4 6/8] perf tests: Use scandirat for shell script finding

On Fri, Feb 16, 2024 at 12:22 PM Namhyung Kim <namhyung@...nel.org> wrote:
>
> On Tue, Feb 13, 2024 at 8:54 PM Ian Rogers <irogers@...gle.com> wrote:
> >
> > Avoid filename appending buffers by using openat, faccessat and
> > scandirat more widely. Turn the script's path back to a file name
> > using readlink from /proc/<pid>/fd/<fd>.
> >
> > Read the script's description using api/io.h to avoid fdopen
> > conversions. Whilst reading perform additional sanity checks on the
> > script's contents.
> >
> > Signed-off-by: Ian Rogers <irogers@...gle.com>
> > ---
> >  tools/perf/tests/builtin-test.c  |  21 ++---
> >  tools/perf/tests/tests-scripts.c | 144 ++++++++++++++++++-------------
> >  tools/perf/tests/tests-scripts.h |   1 -
> >  3 files changed, 95 insertions(+), 71 deletions(-)
> >
> > diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
> > index eff3c62e9b47..6d5001daaf63 100644
> > --- a/tools/perf/tests/builtin-test.c
> > +++ b/tools/perf/tests/builtin-test.c
> > @@ -300,22 +300,20 @@ static int test_and_print(struct test_suite *t, int subtest)
> >  }
> >
> >  struct shell_test {
> > -       const char *dir;
> >         const char *file;
> >  };
> >
> >  static int shell_test__run(struct test_suite *test, int subdir __maybe_unused)
> >  {
> >         int err;
> > -       char script[PATH_MAX];
> >         struct shell_test *st = test->priv;
> > +       char *cmd;
> >
> > -       path__join(script, sizeof(script) - 3, st->dir, st->file);
> > -
> > -       if (verbose > 0)
> > -               strncat(script, " -v", sizeof(script) - strlen(script) - 1);
> > -
> > -       err = system(script);
> > +       asprintf(&cmd, "%s%s", st->file, verbose ? " -v" : "");
> > +       if (!cmd)
> > +               return TEST_FAIL;
>
> It fails to build.
>
> tests/tests-scripts.c: In function ‘shell_test__run’:
> tests/tests-scripts.c:130:9: error: ignoring return value of
> ‘asprintf’ declared with attribute ‘warn_unused_result’
> [-Werror=unused-result]
>   130 |         asprintf(&cmd, "%s%s", file, verbose ? " -v" : "");
>       |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Thanks, 1 liner fix in v5 on its way. I'll add -Werror=unused-result
to my EXTRA_CFLAGS.

Ian

> Thanks,
> Namhyung
>
>
> > +       err = system(cmd);
> > +       free(cmd);
> >         if (!err)
> >                 return TEST_OK;
> >

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ