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>] [day] [month] [year] [list]
Date:   Fri, 21 Jun 2019 16:45:14 +0200
From:   Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To:     Rajat Jain <rajatja@...gle.com>
Cc:     Bjorn Helgaas <bhelgaas@...gle.com>,
        linux-pci <linux-pci@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: PCI/AER sysfs files violate the rules of how sysfs works

On Fri, Jun 21, 2019 at 07:08:38AM -0700, Rajat Jain wrote:
> On Fri, Jun 21, 2019, 12:29 AM Greg KH <gregkh@...uxfoundation.org> wrote:
> 
> > Hi,
> >
> > When working on some documentation scripts to show the
> > Documentation/ABI/ files in an automated way, I ran across this "gem" of
> > a sysfs file: Documentation/ABI/testing/sysfs-bus-pci-devices-aer_stats
> >
> > In it you describe how the files
> > /sys/bus/pci/devices/<dev>/aer_dev_correctable and
> > /sys/bus/pci/devices/<dev>/aer_dev_fatal and
> > /sys/bus/pci/devices/<dev>/aer_dev_nonfatal
> > all display a bunch of text on multiple lines.
> >
> > This violates the "one value per sysfs file" rule, and should never have
> > been merged as-is :(
> >
> > Please fix it up to be a lot of individual files if your really need all
> > of those different values.
> >
> > Remember, sysfs files should never have to have a parser to read them
> > other than a simple "what is this single value", and you should NEVER
> > have fun macros like:
> >
> >         for (i = 0; i < ARRAY_SIZE(strings_array); i++) {               \
> >                 if (strings_array[i])                                   \
> >                         str += sprintf(str, "%s %llu\n",                \
> >                                        strings_array[i], stats[i]);     \
> >                 else if (stats[i])                                      \
> >                         str += sprintf(str, #stats_array "_bit[%d]
> > %llu\n",\
> >                                        i, stats[i]);                    \
> >         }                                                               \
> >         str += sprintf(str, "TOTAL_%s %llu\n", total_string,            \
> >                        pdev->aer_stats->total_field);                   \
> >
> > spit out sysfs information.
> >
> > Note, I am all for not properly checking the length of the sysfs file
> > when writing to it, but that is ONLY because you "know" that a single
> > integer will never overflow anything.  Here you are writing a ton of
> > different values, with no error checking at all.  So just when I thought
> > it couldn't be any worse...
> >
> > Please fix.
> >
> 
> My apologies. I will discuss with Bjorn and fix this.

thank you.  I'll be glad to review patches for this.

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ