[PATCH] staging: vc04_services: Add 32-bit compatibility ioctls

Arnd Bergmann arnd at arndb.de
Tue Nov 8 14:30:22 PST 2016

On Tuesday, November 8, 2016 1:42:03 PM CET Michael Zoran wrote:
> > 
> > Another way of doing compat ioctls that doesn't rewrite your whole
> > non-compat ioctl path is in drivers/gpu/drm/drm_ioc32.c: the compat
> > path
> > just rewrites the 32-bit ioctl into a 64-bit struct that it passes to
> > the normal ioctl handler.
> That really is a cool way to do 32-bit compat. I didn't know it was
> possible to do it that way.

It's not that nice either: since the native handler expects a user
pointer, you either have to use compat_alloc_user_space() and copy
the arguments back to the user space stack, or use set_fs(KERNEL_DS)
to allow fetching user pointers from kernel memory. Both of these
are problematic, especially with nested pointers.

> In this case, the native ioctl mess is so bad that IMHO it's not
> maintainable. Perhaps it is better to fix the mess now while the whole
> driver is still marked "broken" and most of the patches are still in
> linux-next.  

What is the long-term plan for this driver anyway? Is it going to
be replaced with another driver to talk to the firmware, or cleaned
up to the point of graduating out of staging?

In the second case, we can discuss cleaning up the ioctl API to
make the calls entirely compatible between 32-bit and 64-bit
user space at the cost of breaking compatibility with existing
user space binaries. This mainly involves using fixed-size members
for everything, and in particular passing pointers through __u64


More information about the linux-rpi-kernel mailing list