request for snap interface that expose userspace device APIs

Bug #1641752 reported by Jian Luo on 2016-11-14
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
snapd
Medium
Zygmunt Krynicki

Bug Description

Embedded systems (which are likely called IoT devices these days :) sometime need access to peripherals via user-space device APIs, namely i2cdev[1], spidev[2] and uio[3]. Snaps of type core and gadget should be able to expose these interfaces to other privileged snaps.

Accesses to these character special devices should be granted through this interface:
- /dev/spidevB.C rw,ioctl
- /dev/i2c-%d rw,ioctl
- /dev/uio%d rw,mmap,poll,select

Optionally read-only accesses to sysfs entries can be granted to get device information:
- /sys/class/i2c-dev/** r
- /sys/class/uio/** r

Tests can be done with tools in [4] [5] [6] accordingly.

This interface is IMHO similar to bool_file, gpio and serial-port in regards to security concerns.

[1] https://www.kernel.org/doc/Documentation/i2c/dev-interface
[2] https://www.kernel.org/doc/Documentation/spi/spidev
[3] https://www.kernel.org/doc/htmldocs/uio-howto/userspace_driver.html
[4] https://launchpad.net/ubuntu/+source/i2c-tools
[5] https://github.com/torvalds/linux/blob/master/tools/spi/spidev_test.c
[6] http://www.osadl.org/projects/downloads/UIO/user/lsuio-0.2.0.tar.gz

Lorn Potter (lorn-potter) wrote :

There is already an i2c interface,
https://github.com/snapcore/snapd/pull/2113

an iio interface in the works based on the i2c interface.

spidev and uio could also be written based on what i2c is, with obvious changes.

Didier Roche (didrocks) wrote :

The thing is that they are not exposed in gadget snaps for various devices if I'm correct (like the GPIO one). I did open a bug last week for this: https://bugs.launchpad.net/snappy/+bug/1641752

Zygmunt Krynicki (zyga) wrote :

This bug is rather old so I'd like to summarize where we are now:

- there are i2c, iio and spi interfaces in snapd
- there is no uio interface yet

Interfaces must be defined by the gadget but we now have support for hot-plug detection that could be used instead of static declaration.

I'm not familiar with uio devices, can you share some information about development boards that have them? I found updated reference to the kernel documentation here https://www.kernel.org/doc/html/v4.17/driver-api/uio-howto.html but none of the reference platforms for snapd seems to have those.

affects: snappy → snapd
Changed in snapd:
status: New → Confirmed
importance: Undecided → Medium
Zygmunt Krynicki (zyga) wrote :

I've started working on the new interface. Scheduled it for 2.43 but may slip to 2.43.1 depending on release timings.

Changed in snapd:
assignee: nobody → Zygmunt Krynicki (zyga)
status: Confirmed → In Progress
milestone: none → 2.43
Zygmunt Krynicki (zyga) wrote :

I've implemented and tested the interface and proposed it for merging into snapd https://github.com/snapcore/snapd/pull/7863

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers