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: <7c3d2688a1544eb5ea963cd2b07a2ff03d328c4a.camel@gmail.com>
Date:   Tue, 31 Aug 2021 18:13:18 +0200
From:   Riccardo Mancini <rickyman7@...il.com>
To:     Namhyung Kim <namhyung@...nel.org>
Cc:     Arnaldo Carvalho de Melo <acme@...nel.org>,
        Ian Rogers <irogers@...gle.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Mark Rutland <mark.rutland@....com>,
        Jiri Olsa <jolsa@...hat.com>,
        linux-kernel <linux-kernel@...r.kernel.org>,
        linux-perf-users <linux-perf-users@...r.kernel.org>,
        Alexey Bayduraev <alexey.v.bayduraev@...ux.intel.com>
Subject: Re: [RFC PATCH v3 06/15] perf workqueue: introduce workqueue struct

Hi Namhyung,
thanks again for taking your time to review.

On Tue, 2021-08-24 at 12:27 -0700, Namhyung Kim wrote:
> Hi Riccardo,
> 
> On Fri, Aug 20, 2021 at 3:54 AM Riccardo Mancini <rickyman7@...il.com> wrote:
> > +/**
> > + * workqueue_strerror - print message regarding lastest error in @wq
> > + *
> > + * Buffer size should be at least WORKQUEUE_STRERR_BUFSIZE bytes.
> > + */
> > +int workqueue_strerror(struct workqueue_struct *wq, int err, char *buf,
> > size_t size)
> > +{
> > +       int ret;
> > +       char sbuf[THREADPOOL_STRERR_BUFSIZE], *emsg;
> > +       const char *errno_str;
> > +
> > +       errno_str = workqueue_errno_str[-err-WORKQUEUE_ERROR__OFFSET];
> 
> It seems easy to crash with an invalid err argument.

Yup, I should add a check in the next version.

> 
> > +
> > +       switch (err) {
> > +       case -WORKQUEUE_ERROR__POOLNEW:
> > +       case -WORKQUEUE_ERROR__POOLEXE:
> > +       case -WORKQUEUE_ERROR__POOLSTOP:
> > +       case -WORKQUEUE_ERROR__POOLSTARTTHREAD:
> > +               if (IS_ERR_OR_NULL(wq))
> > +                       return scnprintf(buf, size, "%s: unknown.\n",
> > +                               errno_str);
> > +
> > +               ret = threadpool__strerror(wq->pool, wq->pool_errno, sbuf,
> > sizeof(sbuf));
> > +               if (ret < 0)
> > +                       return ret;
> > +               return scnprintf(buf, size, "%s: %s.\n", errno_str, sbuf);
> > +       case -WORKQUEUE_ERROR__WRITEPIPE:
> > +       case -WORKQUEUE_ERROR__READPIPE:
> > +               emsg = str_error_r(errno, sbuf, sizeof(sbuf));
> 
> 
> This means the errno should be kept before calling this, right?

Yeah, I should make sure to preserve it, I think it's done this way in some
other functions.
Otherwise, I can save it in a struct attribute, which is maybe simpler.

> 
> > +               return scnprintf(buf, size, "%s: %s.\n", errno_str, emsg);
> > +       case -WORKQUEUE_ERROR__INVALIDMSG:
> > +               return scnprintf(buf, size, "%s.\n", errno_str);
> > +       default:
> > +               emsg = str_error_r(err, sbuf, sizeof(sbuf));
> > +               return scnprintf(buf, size, "Error: %s", emsg);
> 
> Newline at the end?

Forgot it, thanks!

Riccardo

> 
> Thanks,
> Namhyung
> 
> 
> > +       }
> > +}
> > +


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ