[PATCH RFC] staging: comedi: fix user/kernel space access of cmd->chanlist

H Hartley Sweeten hartleys at visionengravers.com
Tue Sep 18 16:30:17 UTC 2012


On Tuesday, September 18, 2012 9:15 AM, Ian Abbott wrote:
> On 2012-09-18 16:48, H Hartley Sweeten wrote:
>> What about just renaming the user version of the struct and then
>> creating the 'shadowing' kernel struct without the __user tag?
>
> Partly because I've already changed it locally and partly because the 
> current name matches the ioctl it is associated with.

Changed what locally? Are you going to post a patch for this?

As far as the name in to ioctl goes...

My proposed change would make the two structs:

struct comedi_user_cmd {
	...
	unsigned int __user *chanlist;
	...
	short __user *data;
	...
};

struct comedi_cmd {
	...
	unsigned int *chanlist;
	...
	short *data;
	...
};

And the ioctls would be:

#define COMEDI_CMD _IOR(CIO, 9, struct comedi_user_cmd)
#define COMEDI_CMDTEST _IOR(CIO, 10, struct comedi_user_cmd)

Comedilib has this for the ioctls:

#define COMEDI_CMD _IOR(CIO,9,comedi_cmd)
#define COMEDI_CMDTEST _IOR(CIO,10,comedi_cmd)

With comedi_cmd being a typedef. So there is already an ioctl difference between
the kernel and the userspace library.

Regards,
Hartley




More information about the devel mailing list