From: Heiko Carstens <heiko.carstens@de.ibm.com>
To: David Miller <davem@davemloft.net>
Cc: arndbergmann@googlemail.com, airlied@linux.ie,
dri-devel@lists.sourceforge.net, andi@firstfloor.org,
linux-kernel@vger.kernel.org, schwidefsky@de.ibm.com,
Ankit Jain <me@ankitjain.org>, Christoph Hellwig <hch@lst.de>,
Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: is avoiding compat ioctls possible?
Date: Thu, 29 Oct 2009 09:34:16 +0100 [thread overview]
Message-ID: <20091029083415.GA6639@osiris.boeblingen.de.ibm.com> (raw)
In-Reply-To: <20091028.224157.92041844.davem@davemloft.net>
On Wed, Oct 28, 2009 at 10:41:57PM -0700, David Miller wrote:
> From: Arnd Bergmann <arndbergmann@googlemail.com>
> Date: Wed, 28 Oct 2009 16:40:18 +0100
>
> > I'm pretty sure it was ok when we started adding the compat_ioctl
> > handlers years ago. I think most people just ignored these for
> > the majority of drivers that can't possibly run on s390. Even
> > on s390, gcc will always do the right thing if you call call ioctl
> > with a pointer to a normal object in the .data section, heap or stack,
> > but hand-written assembly or other compilers may not.
>
> Arnd, even compat_sys_ioctl() itself has constructs like:
>
> case FS_IOC_RESVSP:
> case FS_IOC_RESVSP64:
> error = ioctl_preallocate(filp, (void __user *)arg);
> goto out_fput;
That's broken, but it's quite new code. In general it looks like we don't
have many compat ioctl problems on s390. At least I don't remember when
we faced the last bug.
We did have some compat syscall issues when SLES11 testing started.
The lack of bug reports is probably just a lack of 32 bit userspace ;)
This should fix at least the bug above:
Subject: [PATCH] fs: add missing compat_ptr handling for FS_IOC_RESVSP ioctl
From: Heiko Carstens <heiko.carstens@de.ibm.com>
For FS_IOC_RESVSP and FS_IOC_RESVSP64 compat_sys_ioctl() uses its
arg argument as a pointer to userspace. However it is missing a
a call to compat_ptr() which will do a proper pointer conversion.
This was introduced with 3e63cbb1 "fs: Add new pre-allocation ioctls
to vfs for compatibility with legacy xfs ioctls".
Cc: Ankit Jain <me@ankitjain.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Arnd Bergmann <arndbergmann@googlemail.com>
Reported-by: David Miller <davem@davemloft.net>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
fs/compat_ioctl.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index f91fd51..d84e705 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -1800,7 +1800,7 @@ struct space_resv_32 {
/* just account for different alignment */
static int compat_ioctl_preallocate(struct file *file, unsigned long arg)
{
- struct space_resv_32 __user *p32 = (void __user *)arg;
+ struct space_resv_32 __user *p32 = compat_ptr(arg);
struct space_resv __user *p = compat_alloc_user_space(sizeof(*p));
if (copy_in_user(&p->l_type, &p32->l_type, sizeof(s16)) ||
@@ -2802,7 +2802,7 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
#else
case FS_IOC_RESVSP:
case FS_IOC_RESVSP64:
- error = ioctl_preallocate(filp, (void __user *)arg);
+ error = ioctl_preallocate(filp, compat_ptr(arg));
goto out_fput;
#endif
next prev parent reply other threads:[~2009-10-29 8:34 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-28 1:22 Dave Airlie
2009-10-28 2:25 ` David Miller
2009-10-28 3:01 ` Dave Airlie
2009-10-28 2:53 ` Andi Kleen
2009-10-28 3:05 ` Dave Airlie
2009-10-28 3:19 ` Andi Kleen
2009-10-28 3:28 ` Dave Airlie
2009-10-28 3:34 ` Andi Kleen
2009-10-28 3:43 ` David Miller
2009-10-28 3:41 ` David Miller
2009-10-28 21:05 ` Maciej W. Rozycki
2009-10-29 8:27 ` Arnd Bergmann
2009-10-28 3:38 ` David Miller
2009-10-28 3:43 ` Dave Airlie
2009-10-28 3:45 ` David Miller
2009-10-28 3:51 ` Andi Kleen
2009-10-28 3:54 ` Dave Airlie
2009-10-28 5:28 ` David Miller
2009-10-28 5:42 ` Dave Airlie
2009-10-28 6:04 ` David Miller
2009-10-28 7:53 ` David Miller
2009-10-28 7:59 ` Andi Kleen
2009-10-28 8:11 ` David Miller
2009-10-28 8:19 ` Andi Kleen
2009-10-28 8:28 ` David Miller
2009-10-28 12:13 ` Arnd Bergmann
2009-10-28 12:16 ` David Miller
2009-10-28 15:40 ` Arnd Bergmann
2009-10-29 5:41 ` David Miller
2009-10-29 8:16 ` Arnd Bergmann
2009-10-29 8:34 ` Heiko Carstens [this message]
2009-10-29 8:39 ` David Miller
2009-10-28 12:17 ` David Miller
2009-10-30 1:13 ` Dave Airlie
2009-10-30 10:13 ` Arnd Bergmann
2009-11-18 0:26 ` Dave Airlie
2009-11-18 9:09 ` Andi Kleen
2009-11-18 14:42 ` Arnd Bergmann
2009-10-28 3:37 ` David Miller
2009-10-28 4:36 ` Andi Kleen
2009-10-28 5:29 ` David Miller
2009-10-28 10:27 ` 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=20091029083415.GA6639@osiris.boeblingen.de.ibm.com \
--to=heiko.carstens@de.ibm.com \
--cc=airlied@linux.ie \
--cc=andi@firstfloor.org \
--cc=arndbergmann@googlemail.com \
--cc=davem@davemloft.net \
--cc=dri-devel@lists.sourceforge.net \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=me@ankitjain.org \
--cc=schwidefsky@de.ibm.com \
--cc=viro@zeniv.linux.org.uk \
/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
Powered by JetHome