32->64 bit conversion for wireless private ioctl
Subsystems (4)
PATCH 1/1 32->64 bit conversion for wireless private ioctl
Hi all,
(Sorry for the spam)
The Wireless Extensions use a bunch of driver specific
ioctl. Jeff told me that those can't be safe when running a 32 bit userspace on a 64 bit kernel. So, I did a patch...
Patch is for kernel 2.6.5.
Treat this patch as a proof of concept. I don't have any 64
bit machine, so no way to compile it (without talking of actually testing it). But this is where I hope you guys will help me ;-)
Waiting for your feedback, Have fun... Jean
----------------------------------------------------------------
include/net/iw_handler.h renamed from include/net/iw_handler.p1.h +3 -0
@@ -412,6 +412,9 @@ struct iw_public_data {* Those may be called only within the kernel. */ +/* Data needed by fs/compat_ioctl.c for 32->64 bit conversion */ +extern const char iw_priv_type_size[]; +/* First : function strictly used inside the kernel */ /* Handle /proc/net/wireless, called in net/code/dev.c */
net/core/wireless.c renamed from net/core/wireless.p1.c +2 -2
@@ -301,7 +301,7 @@ static const int standard_event_num = (s sizeof(struct iw_ioctl_description));/* Size (in bytes) of the various private data types */ -static const char priv_type_size[] = { +const char iw_priv_type_size[] = {0 ,/* IW_PRIV_TYPE_NONE */ 1 ,/* IW_PRIV_TYPE_BYTE */ 1 ,/* IW_PRIV_TYPE_CHAR */
@@ -415,7 +415,7 @@ static inline int get_priv_size(__u16 arint num = args &IW_PRIV_SIZE_MASK ;int type = (args &IW_PRIV_TYPE_MASK ) >>12 ; -return num * priv_type_size[type]; +return num * iw_priv_type_size[type]; }
fs/compat_ioctl.c renamed from fs/compat_ioctl.p1.c +108 -0
126 lines not on this page · raw message
Quoted 4 lines · Jean Tourrilhes
Hi all,
(Sorry for the spam)
Quoted 8 lines
The Wireless Extensions use a bunch of driver specific
ioctl. Jeff told me that those can't be safe when running a 32 bit userspace on a 64 bit kernel. So, I did a patch...
Patch is for kernel 2.6.5.Treat this patch as a proof of concept. I don't have any 64
bit machine, so no way to compile it (without talking of actually testing it). But this is where I hope you guys will help me ;-)
You missed what I was trying to communicate :(
It is a logical contradiction to create a generic interface for driver-private ioctls. You wind up re-inventing Sun XDR.
fs/compat_ioctl.c static int do_wireless_ioctl(unsigned in · line 3114
Quoted 5 lines
fs/compat_ioctl.c renamed from fs/compat_ioctl.p1.c +5
-0+/* Get the description of the IOCTL */ +for (i =0 ; i < dev->wireless_handlers->num_private_args; i++) +if (cmd == dev->wireless_handlers->private_args[i].cmd) { + descr = &(dev->wireless_handlers->private_args[i]); +break ;
This is essentially runtime definition of structures types.
We want to go in the opposite direction: compile and verify as much code as possible at compile time. Strong, compile-time type checking.
Jeff
Quoted 5 lines · Jeff Garzik
You missed what I was trying to communicate :(
It is a logical contradiction to create a generic interface for driver-private ioctls. You wind up re-inventing Sun XDR.
Any interface for device specific stuff has to be generic, it
doesn't matter if you use ioctl, netlink, module parameters or pseudo-filesystem.
Now, we can debate if this generic interface should use ioctl
or something else, that's a different issue. I hope you will have noticed that some drivers, such as Orinoco, got rid of their pseudo-filesystem and converted to iwpriv (you may ask David why he did that). So, it's probably not as bad as you claim...
The point is that this interface exist, is in use, so we might
as well make it 64 bit clean. Therefore patch.
Quoted 2 lines
We want to go in the opposite direction: compile and verify as much code as possible at compile time. Strong, compile-time type checking.
I wonder how you are going to do that for device specific
stuff with strong compile time checks. If you convert everything to a binary pseudo-file, which doesn't change anything to the problem. Or you can use a text pseudo-file, which mean a dedicated parser or a generic parsing infrastructure, and performance penalty. You can't win.
Maybe all the device specific APIs should use XML. That's the
future, and allow to validate the userspace input. Next week, I'll convert all Wireless Extension to XML ;-)
Quoted 1 line
Jeff
Regards,
Jean
Quoted 16 lines · Jean Tourrilhes
Quoted 5 lines · Jeff Garzik
You missed what I was trying to communicate :(
It is a logical contradiction to create a generic interface for driver-private ioctls. You wind up re-inventing Sun XDR.
Any interface for device specific stuff has to be generic, it
doesn't matter if you use ioctl, netlink, module parameters or pseudo-filesystem.
Now, we can debate if this generic interface should use ioctl
or something else, that's a different issue. I hope you will have noticed that some drivers, such as Orinoco, got rid of their pseudo-filesystem and converted to iwpriv (you may ask David why he did that). So, it's probably not as bad as you claim...
Quoted 2 lines
The point is that this interface exist, is in use, so we might
as well make it 64 bit clean. Therefore patch.
You're still missing the point. This 'private_args' interface should not exist at all. Making it 64-bit clean doesn't help anything (it still needs to be endian clean as well, but even that's not the point). It's a run-time type interface when all other net drivers have managed to avoid such a thing. It's overly complex, and is a "black hole" interface that discourages wireless authors from coming together and developing more common pieces.
It's just not Linux in so many ways. Please, look at how the other interfaces in the kernel are designed, and how they evolve over time.
Quoted 5 lines
Quoted 2 lines
We want to go in the opposite direction: compile and verify as much code as possible at compile time. Strong, compile-time type checking.
I wonder how you are going to do that for device specific
stuff with strong compile time checks. If you convert everything to a
See various implementations of SIOCDEVPRIVATE.
Jeff