linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: y2038@lists.linaro.org
Cc: John Stultz <john.stultz@linaro.org>,
	Bamvor Zhang Jian <bamvor.zhangjian@linaro.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	lkml <linux-kernel@vger.kernel.org>
Subject: Re: [Y2038] [RFC PATCH v2 3/4] ppdev: add compat ioctl
Date: Wed, 08 Jul 2015 23:28:04 +0200	[thread overview]
Message-ID: <26603653.9xWxRUDZUD@wuerfel> (raw)
In-Reply-To: <CALAqxLUSVEbGicEiAjO=bEcMw4L=djjGLQTfEni6S8skk+H=Og@mail.gmail.com>

On Wednesday 08 July 2015 13:17:18 John Stultz wrote:
> On Mon, Jun 29, 2015 at 7:23 AM, Bamvor Zhang Jian
> <bamvor.zhangjian@linaro.org> wrote:
> > Add compat ioctl in ppdev in order to solve the y2038 issue in
> > later patch.
> > This patch simply add pp_do_ioctl to compat_ioctl, because I found
> > that all the ioctl access the arg as a pointer.
> >
> > Signed-off-by: Bamvor Zhang Jian <bamvor.zhangjian@linaro.org>

I just saw this mail fly by when you replied, but I guess it would
have been better to reply when the original mail came.

The description above makes no sense: The problem for compat ioctl
is not whether the argument is a pointer or not, but rather what
data structure it points to. In this case, we already know that 
it is /not/ compatible between 32-bit and 64-bit user space, because
at least two commands need special handling for the timespec
argument, which gets added in patch 4 of the series.

This means patches 3 and 4 have to be swapped in order to allow
bisection and not introduce a bug when only this one gets applied
but patch 4 is missing.

Moreover, all other ioctl commands that are handled in pp_ioctl
need to be checked regarding what their arguments are, including
data structures pointed to by the arguments (recursively, if there
are again pointers in those structures).

> >         unsigned int minor = iminor(inode);
> > @@ -744,6 +750,9 @@ static const struct file_operations pp_fops = {
> >         .write          = pp_write,
> >         .poll           = pp_poll,
> >         .unlocked_ioctl = pp_ioctl,
> > +#ifdef CONFIG_COMPAT
> > +       .compat_ioctl   = pp_compat_ioctl,
> > +#endif

The #ifdef here is not necessary, but will cause a warning on kernels 
that do not define CONFIG_COMPAT, in particular all 32-bit ones.

> Does adding this patch w/o the following patch break 32bit apps using
> this on 64bit kernels?

Without the patch, those apps will all get -EINVAL from the ioctl
handler. With the patch, the kernel actually performs the ioctl
that was requested, but that may use the wrong data structure.

	Arnd

  reply	other threads:[~2015-07-08 21:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-29 14:23 [RFC PATCH v2 0/4] Convert ppdev to y2038 safe Bamvor Zhang Jian
2015-06-29 14:23 ` [RFC PATCH v2 1/4] y2038: add 64bit time_t support in timeval for 32bit architecture Bamvor Zhang Jian
2015-07-08 20:09   ` John Stultz
2015-07-09  9:02     ` Bamvor Zhang Jian
2015-07-09 10:26       ` Arnd Bergmann
2015-07-15  3:18         ` Bamvor Zhang Jian
2015-07-15  9:33           ` Arnd Bergmann
2015-06-29 14:23 ` [RFC PATCH v2 2/4] time64: add timeval64 helper for compat syscalls Bamvor Zhang Jian
2015-06-29 14:23 ` [RFC PATCH v2 3/4] ppdev: add compat ioctl Bamvor Zhang Jian
2015-07-08 20:17   ` John Stultz
2015-07-08 21:28     ` Arnd Bergmann [this message]
2015-06-29 14:23 ` [RFC PATCH v2 4/4] y2038: convert ppdev to 2038 safe Bamvor Zhang Jian
2015-07-08 21:34   ` Arnd Bergmann
2015-07-08 21:36   ` Arnd Bergmann

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=26603653.9xWxRUDZUD@wuerfel \
    --to=arnd@arndb.de \
    --cc=bamvor.zhangjian@linaro.org \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=y2038@lists.linaro.org \
    /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;
as well as URLs for NNTP newsgroup(s).