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]
Date:   Mon, 6 Sep 2021 11:04:00 +0200
From:   Wolfram Sang <wsa+renesas@...g-engineering.com>
To:     Andy Shevchenko <andy.shevchenko@...il.com>
Cc:     "open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
        Linux-Renesas <linux-renesas-soc@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Linus Walleij <linus.walleij@...aro.org>
Subject: Re: [PATCH 1/1] gpio: add sloppy logic analyzer using polling

Hi Andy,

thank you for the review again!

> > +       unsigned long state = 0; /* zeroed because GPIO arrays are bitfields */
> 
> Not sure if bitmap_zero() would be better. Up to you.

Looks cleaner, I'll check.

> > +static int fops_buf_size_set(void *data, u64 val)
> > +{
> > +       struct gpio_la_poll_priv *priv = data;
> > +       int ret = 0;
> > +       void *p;
> > +
> > +       if (!val)
> 
> > +               return -EINVAL;
> 
> Hmm... in this case you haven't updated the internal parameters, but...
> 
> > +       mutex_lock(&priv->lock);
> > +
> > +       vfree(priv->blob.data);
> > +       p = vzalloc(val);
> > +       if (!p) {
> > +               val = 0;
> > +               ret = -ENOMEM;
> 
> ...here you do. What's the difference?

vfree(). In the latter case, the old buffer is already gone.


> > +       if (ret >= 0 && ret != priv->descs->ndescs)
> 
> > +               ret = -ENOSTR;
> 
> A bit of an unusual error code.
> Perhaps -ENODATA?

OK, as long as it is unique...

> > +               /* '10' is length of 'probe00=\n\0' */
> 
> Maybe instead of comment is to use respective strlen():s / sizeof():s?
> 
> Actually, looking below possible option is
> 
> const char *fmt = "probe...";
> 
> add_len += sprintf(NULL, 0, fmt, 0, "");
> 
> ...
> 
> snprintf(..., fmt, ...);
> 
> But it's up to you.
> 
> > +               add_len = strlen(gpio_names[i]) + 10;
> > +
> > +               new_meta = devm_krealloc(dev, meta, meta_len + add_len, GFP_KERNEL);
> > +               if (!new_meta)
> > +                       return -ENOMEM;
> > +
> > +               meta = new_meta;
> > +               snprintf(meta + meta_len, add_len, "probe%02d=%s\n", i + 1, gpio_names[i]);
> 
> > +               /* ' - 1' to skip the NUL terminator */
> > +               meta_len += add_len - 1;
> 
> Reuse return value from snprintf()?

I will have a look at these string refactorings when I need the analyzer
next time and come back then.

> 
> > +       }
> 
> ...
> 
> > +static int gpio_la_poll_remove(struct platform_device *pdev)
> > +{
> > +       struct gpio_la_poll_priv *priv = platform_get_drvdata(pdev);
> > +
> > +       mutex_lock(&priv->lock);
> > +       debugfs_remove_recursive(priv->debug_dir);
> > +       mutex_unlock(&priv->lock);
> 
> mutex_destroy()?

Oh yes, thank you!

> 
> > +
> > +       return 0;
> > +}
> 
> ...
> 
> > +#!/bin/sh -eu
> 
> Next step is to add 'f' to the mix here :-)

-f broke zip file generation in a way I didn't know how to resolve
differently. Sadly, I can't recall the details right now.

> 
> ...
> 
> > +$0 - helper script for the Linux Kernel Sloppy GPIO Logic Analyzer
> 
> Use at the top something like
> 
> PROG_NAME="${0##*/}"

I like this!

> echo "$2'
> exit $1

I don't see the need now. We can update if we need it.

> > +       [ -n "$cur_cpu" ] && fail "CPU$isol_cpu requested but CPU$cur_cpu already isolated"
> 
> This theoretically may fail the script since you have '-e'.
> I guess I have mentioned that 'a && b' is not an equivalent to 'if-then-fi'.
> I suggest double checking all similar expressions and try under
> different shells (like dash).

Well, from the cover-letter:

* A *lot* of cleanups to the shell script guided by checkers, mainly
  'shellcheck'. This is mainly to ensure that the scripts works on most
  minimal shells. Tested are 'busybox ash', 'dash', and 'bash'.

> > +       [ -w "$cpufreqgov" ] && echo 'performance' > "$cpufreqgov" || true
> 
> I guess this is where you actually hit the above mentioned difference.

I used a different kernel on a different SoC which did not have CPUfreq
at all.

> 
> ...
> 
> > +while true; do
> > +       case "$1" in
> > +       -c|--cpu) initcpu="$2"; shift 2;;
> > +       -d|--duration-us) duration="$2"; shift 2;;
> > +       -h|--help) print_help; exit 0;;
> > +       -i|--instance) lasysfsdir="$sysfsdir/$2"; shift 2;;
> > +       -k|--kernel-debug-dir) debugdir="$2"; shift 2;;
> > +       -n|--num_samples) numsamples="$2"; shift 2;;
> > +       -o|--output-dir) outputdir="$2"; shift 2;;
> > +       -s|--sample_freq) samplefreq="$2"; shift 2;;
> > +       -t|--trigger) triggerdat="$2"; shift 2;;
> > +       --)     shift; break;;
> > +       *)      fail "error parsing commandline: $*";;
> > +       esac
> 
> I would prefer to have a clear shift here instead of doing shift 2
> everywhere above (less error prone).

If we ever support binary arguments (toggles), then a generic 'shift 2'
won't work?

> 
> > +done
> 
> ...
> 
> I think usage of SI units makes sense to be less error prone in case
> you are using them more than once.

SI would be useful, for sure. But I need to move on right now, so it
needs to be done incrementally.

All the best,

   Wolfram


Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ