While ioctls are officially ugly, they are the best choice for somethis doesn't seem to be much different from the way the DRM code deals
use cases, not to mention compatibility issues. Currently ioctl
writers face the following hurdles:
- if the ioctl uses a data buffer, the ioctl handler must allocate
kernel memory for this buffer
- the memory may be allocated on the heap or on the stack,
depending on the buffer size
- handle any errors from the operation
- copy the data from userspace, if necessary
- handle any errors from the operation
- actually perform the operation
- copy the data back to userspace, if necessary
- handle any errors from the operation
- free the buffer, if allocated from the heap
The first patch automates these operations, only requiring the caller
to supply the ioctl number and a callback in a table.
with ioctls. Or the V4L code.
Personally I hate that code though.....
There is a fine balance here; between driver writers screwing something
up they shouldn't be doing in the first place and us being able to
clearly see what the code is doing; your patch kinda hides some key
elements of the ioctl path...
I'm afraid it gives a false sense of
security though. Not having to deal with one aspect of security just to
have to deal with the rest....
Lets put it this way: if the driver author has to type "copy_from_user"
there's a chance that he'll remember that the data comes from the user
and isn't to be trusted on face value.