[ktap] [PATCH 0/4] suggestion on kernel interface

Hi,

Please find some patches that could help to improve
the kernel interface used by ktap.

I've seen ktap briefly part of linux-next and look at it
in order to make it use O_CLOEXEC. But while looking
at this issue I've found some oddities on the kernel
interface exposed by ktap.

These are only suggestion and not definitive patches.
In particular, adding patches changing anon_inode_getfile
and adding O_CLOEXEC are of no use if the following changes
are implemented instead.

In particular, Ktap kernel interface should probably
be defined by write() (and read()) instead of ioctl().

See "Linux Device Drivers, 3rd edition",
"Chapter 6: Advanced Char Driver Operations",
especially "ioctl" (page 136) and 
"Device Control Without ioctl" (page 146)

http://lwn.net/images/pdf/LDD3/ch06.pdf

Additionally, but not implemented in this patchset,

- the "chunk" should be put after the "parm" header,
  same apply for args, otherwise, using pointer makes
  ktap not usable by a 32 bits program running on 64 bits
  host, but who would do this ...

- use a "flags" field instead of so many 'int' in ktap_parm
  which map to a boolean value;

- add a version and/or magic field in the ktap_parm to make
  it possible to support further versions and able to reject
  random stream;

- merge transport with ktapvm handling would make it safer
  to read traces: only one device to open, writing on ktapvm
  device would upload opcodes, start/stop execution,
  reading on ktapvm device would retrieve the traces;

- move code reading/writing from userspace together in the same
  module to make it easier to audit.

As a starting point, you could have a look at the uverbs API
from the InfiniBand / RDMA subsystem:

http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/infiniband/core/uverbs_main.c#n587
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/infiniband/core/uverbs_cmd.c

Regards.


Yann Droneaud (4):
  ktap: use anon_inode_getfd()
  ktap: add support for passing opening flags in ioctl
  ktap: add support for write() operation
  ktap: remove uneeded ioctls

 include/ktap_types.h |  8 -------
 interpreter/ktap.c   | 65 +++++++++++++++++++---------------------------------
 2 files changed, 24 insertions(+), 49 deletions(-)

-- 
1.8.3.1


Other related posts: