puzzle of ioctl decode in file_ioctl.c and userfaultfd.c

Dmitry V. Levin ldv at altlinux.org
Mon Dec 12 11:04:42 UTC 2016


On Mon, Dec 12, 2016 at 10:39:43AM +0000, Dr. David Alan Gilbert wrote:
> * jingpiao chen (chenjingpiao at gmail.com) wrote:
> > Version:4.14-ab28d7f1e5ab9b51f5708741bd13f92e768123d4
> > 
> > 2.userfaultfd.c:126
> > 
> > 126         case UFFDIO_UNREGISTER:
> > 127         case UFFDIO_WAKE: {
> > 128                 struct uffdio_range ura;
> > 129                 tprints(", ");
> > 130                 if (!umove_or_printaddr(tcp, arg, &ura))
> > 131                         tprintf_uffdio_range(&ura);
> > 132                 return RVAL_DECODED | 1;
> > 133         }
> > 
> > /usr/include/linux/userfaultfd.h:
> > 51 #define UFFDIO_UNREGISTER       _IOR(UFFDIO, _UFFDIO_UNREGISTER,        \
> > 52                                      struct uffdio_range)
> > 53 #define UFFDIO_WAKE             _IOR(UFFDIO, _UFFDIO_WAKE,      \
> > 54                                      struct uffdio_range)
> > 
> > UFFDIO_UNREGISTER and UFFDIO_WAKE are read data, why it get data
> > when entering.
> > I means it should replace by:
> 
> >From memory, the problem is that the kernel macros are wrong (and
> can't be fixed since they'd break ABI).  
> In both those calls it's userland who passes data to the kernel
> (giving the address range to be unregisters/woken).

Exactly, this has been discussed here already, citing myself from
https://sourceforge.net/p/strace/mailman/message/35072888/

whoever marked these two ioctls with _IOR has clearly missed the point:
an ioctl that passes data from userspace to the kernel is a write ioctl
and should be marked with _IOW.  Now it's too late to change the ABI and
we'll have to live with two write-only _IOR ioctls.


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20161212/0625ae57/attachment.bin>


More information about the Strace-devel mailing list