public inbox for linux-gpio@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>,
	"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
	Kent Gibson <warthog618@gmail.com>,
	Christoph Hellwig <hch@infradead.org>
Subject: Re: [PATCH v2] gpiolib: Fix line event handling in syscall compatible mode
Date: Mon, 14 Sep 2020 18:01:25 +0300	[thread overview]
Message-ID: <20200914150125.GH3956970@smile.fi.intel.com> (raw)
In-Reply-To: <CAK8P3a1Eh=UuGZSEduHvutK8VYyWJcovheoWYXykwRoQuWAqtQ@mail.gmail.com>

On Mon, Sep 14, 2020 at 04:55:31PM +0200, Arnd Bergmann wrote:
> On Mon, Sep 14, 2020 at 4:37 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > The introduced line even handling ABI in the commit
> >
> >   61f922db7221 ("gpio: userspace ABI for reading GPIO line events")
> >
> > missed the fact that 64-bit kernel may serve for 32-bit applications.
> > In such case the very first check in the lineevent_read() will fail
> > due to alignment differences.
> >
> > To workaround this introduce lineeven_to_user() helper which returns actual
> > size of the structure and copies its content to user if asked.
> >
> > Fixes: 61f922db7221 ("gpio: userspace ABI for reading GPIO line events")
> > Suggested-by: Arnd Bergmann <arnd@arndb.de>
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> Acked-by: Arnd Bergmann <arnd@arndb.de>

Thanks!

> > diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c
> > index e6c9b78adfc2..95af4a470f1e 100644
> > --- a/drivers/gpio/gpiolib-cdev.c
> > +++ b/drivers/gpio/gpiolib-cdev.c
> > @@ -423,6 +423,21 @@ static __poll_t lineevent_poll(struct file *file,
> >         return events;
> >  }
> >
> > +static ssize_t lineevent_get_size(void)
> > +{
> > +#ifdef __x86_64__
> > +       /* i386 has no padding after 'id' */
> > +       if (in_ia32_syscall()) {
> 
> Christoph Hellwig has recently suggested adding a new macro for this
> that would be always available and just evaluate to false on other
> architectures.
> 
> I'd just merge your version for now and backport to to stable kernels,
> but change this instance and a couple of others to use the new
> macro in mainline afterwards.
> 
> Incidentally that would also address CONFIG_OABI_COMPAT
> mode, if anyone cares.

Good to know (for both items).

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2020-09-14 15:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-14 14:37 [PATCH v2] gpiolib: Fix line event handling in syscall compatible mode Andy Shevchenko
2020-09-14 14:55 ` Arnd Bergmann
2020-09-14 15:01   ` Andy Shevchenko [this message]
2020-09-14 23:05 ` Kent Gibson
2020-09-15  9:11   ` Andy Shevchenko
2020-09-15  9:20   ` Andy Shevchenko
2020-09-15 12:18     ` Kent Gibson
2020-09-15 12:56       ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200914150125.GH3956970@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=bgolaszewski@baylibre.com \
    --cc=hch@infradead.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=warthog618@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox