Thread (28 messages) 28 messages, 7 authors, 2019-04-25

Re: [PATCH v3 12/26] compat_ioctl: move more drivers to compat_ptr_ioctl

From: Al Viro <viro@zeniv.linux.org.uk>
Date: 2019-04-25 16:43:09
Also in: amd-gfx, ceph-devel, dri-devel, linux-btrfs, linux-crypto, linux-fsdevel, linux-iio, linux-input, linux-media, linux-pci, linux-rdma, linux-remoteproc, linux-scsi, linux-usb, linux-wireless, lkml, nvdimm, platform-driver-x86, sparclinux

On Thu, Apr 25, 2019 at 05:55:23PM +0200, Arnd Bergmann wrote:
On Thu, Apr 25, 2019 at 5:35 PM Al Viro [off-list ref] wrote:
quoted
On Thu, Apr 25, 2019 at 12:21:53PM -0300, Mauro Carvalho Chehab wrote:
quoted
If I understand your patch description well, using compat_ptr_ioctl
only works if the driver is not for s390, right?
No; s390 is where "oh, just set ->compat_ioctl same as ->unlocked_ioctl
and be done with that; compat_ptr() is a no-op anyway" breaks.  IOW,
s390 is the reason for having compat_ptr_ioctl() in the first place;
that thing works on all biarch architectures, as long as all stuff
handled by ->ioctl() takes pointer to arch-independent object as
argument.  IOW,
        argument ignored => OK
        any arithmetical type => no go, compat_ptr() would bugger it
        pointer to int => OK
        pointer to string => OK
        pointer to u64 => OK
        pointer to struct {u64 addr; char s[11];} => OK
To be extra pedantic, the 'struct {u64 addr; char s[11];} '
case is also broken on x86, because sizeof (obj) is smaller
on i386, even though the location of the members are
the same. i.e. you can copy_from_user() this, but not
copy_to_user(), which overwrites 4 bytes after the end of
the 20-byte user structure.
D'oh!  FWIW, it might be worth putting into Documentation/ somewhere;
basically, what is and what isn't biarch-neutral.

Or arch-neutral, for that matter - it's very close.  The only real
exception, IIRC, is an extra twist on m68k, where int behaves
like x86 long long - its alignment is only half its size, so
sizeof(struct {char c; int x;}) is 6, not 8 as everywhere
else.  Irrelevant for biarch, thankfully (until somebody gets insane
enough to implement 64bit coldfire, kernel port for it *and* biarch
support for m68k binaries on that thing, that is)...
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help