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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMRc=McjOhUBa0QQbZYh0f_2rN=ESxAtPROAzXEt+KNDJKqWiQ@mail.gmail.com>
Date:   Tue, 20 Sep 2022 22:35:25 +0200
From:   Bartosz Golaszewski <brgl@...ev.pl>
To:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc:     Kent Gibson <warthog618@...il.com>,
        Linus Walleij <linus.walleij@...aro.org>,
        linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] gpiolib: cdev: add fdinfo output for line request file descriptors

On Tue, Sep 20, 2022 at 7:19 PM Andy Shevchenko
<andriy.shevchenko@...ux.intel.com> wrote:
>
> On Tue, Sep 20, 2022 at 03:54:35PM +0200, Bartosz Golaszewski wrote:
> > Add fdinfo output for file descriptors created for user-space line
> > requests in GPIO uAPI v2. The fdinfo file now contains the name of the
> > GPIO device that is the "parent" of the request as well as offsets of
> > the lines requested. This allows user-space to parse the /proc/$PID/fdinfo
> > entries and deduct the PID of the process that requested a specific line.
>
> In principle I'm fine, but see below.
>
> > Signed-off-by: Bartosz Golaszewski <brgl@...ev.pl>
> > ---
> >  drivers/gpio/gpiolib-cdev.c | 18 ++++++++++++++++++
> >  1 file changed, 18 insertions(+)
> >
> > diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c
> > index f8041d4898d1..0f7b5562c410 100644
> > --- a/drivers/gpio/gpiolib-cdev.c
> > +++ b/drivers/gpio/gpiolib-cdev.c
> > @@ -1497,6 +1497,21 @@ static int linereq_release(struct inode *inode, struct file *file)
> >       return 0;
> >  }
> >
> > +#ifdef CONFIG_PROC_FS
> > +static void linereq_show_fdinfo(struct seq_file *out, struct file *file)
> > +{
> > +     struct linereq *lr = file->private_data;
> > +     struct device *dev = &lr->gdev->dev;
> > +     u16 i;
> > +
> > +     seq_printf(out, "gpio-device:\t%s\n", dev_name(dev));
> > +
> > +     for (i = 0; i < lr->num_lines; i++)
> > +             seq_printf(out, "gpio-line:\t%d\n",
> > +                        gpio_chip_hwgpio(lr->lines[i].desc));
>
> Hmm... Not sure which variant is better (as for machine parsing and for human),
> but I was thinking of
>

IMO it's pretty clear that the variant in this patch is easier for
machine parsing - one less tokenization.

>         gpio-lines: 1,4,6, ...
>
> Also don't forget that sizes over PAGE_SIZE in sysfs sometimes problematic and
> racy.(the commit 888be6067b97 ("ACPI: sysfs: Fix a buffer overrun problem with
> description_show()") for the reference).
>

In most systems PAGE_SIZE will be at least 4096 bytes. With this patch
a single "gpio-line:\t65535\n" is at most 17 bytes long x max 64 lines
= 1088 bytes. We're still way below the size where it would be
problematic.

Bart

> > +}
> > +#endif
> > +
> >  static const struct file_operations line_fileops = {
> >       .release = linereq_release,
> >       .read = linereq_read,
> > @@ -1507,6 +1522,9 @@ static const struct file_operations line_fileops = {
> >  #ifdef CONFIG_COMPAT
> >       .compat_ioctl = linereq_ioctl_compat,
> >  #endif
> > +#ifdef CONFIG_PROC_FS
> > +     .show_fdinfo = linereq_show_fdinfo,
> > +#endif
> >  };
> >
> >  static int linereq_create(struct gpio_device *gdev, void __user *ip)
> > --
> > 2.34.1
> >
>
> --
> With Best Regards,
> Andy Shevchenko
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ