Interfaces: hardware-observe #1563

Merged
merged 11 commits into from Jul 26, 2016

Conversation

Projects
None yet
4 participants
Contributor

cwayne18 commented Jul 18, 2016

This adds an interface to pull some hardware information from the system, and is needed to be able to run checkbox on a snappy system without --devmode.

cwayne18 added some commits Jul 18, 2016

@cwayne18 cwayne18 changed the title from Hardware observe to Interfaces: hardware-observe Jul 18, 2016

interfaces/builtin/hardware_observe.go
+/bin/udevadm ixr,
+/bin/lsblk ixr,
+/usr/sbin/dmidecode ixr,
+/usr/bin/lsusb ixr,
@zyga

zyga Jul 18, 2016

Contributor

Is lsusb actually in the image? I would say that after having the permissions granted by this interface it would be better to ship the software that has no daemon component (not udev) as a snap itself.

interfaces/builtin/hardware_observe.go
+
+/bin/udevadm ixr,
+/bin/lsblk ixr,
+/usr/sbin/dmidecode ixr,
@zyga

zyga Jul 18, 2016

Contributor

I know why we use it but this is legacy and I don't even know if it is in the image.

interfaces/builtin/hardware_observe.go: Remove lines for dmidecode &&…
… lsusb, as they aren't included in the image as it is
interfaces/builtin/hardware_observe.go
+// http://bazaar.launchpad.net/~ubuntu-security/ubuntu-core-security/trunk/view/head:/data/apparmor/policygroups/ubuntu-core/16.04/log-observe
+const hardwareObserveConnectedPlugAppArmor = `
+# Description: This interface allows for getting hardware information
+# from the system, as is needed by checkbox on snappy. This is reserved for OS snap.
@morphis

morphis Jul 18, 2016

Contributor

I would say we drop the actual reference to a specific snap here.

interfaces/builtin/hardware_observe.go
+/var/lib/usbutils/usb.ids r,
+/sys/firmware/dmi/tables/DMI r,
+/sys/firmware/dmi/tables/smbios_entry_point r,
+
@morphis

morphis Jul 18, 2016

Contributor

Lets drop unnecessary new lines

Contributor

zyga commented Jul 19, 2016

Please patch docs/interfaces.md to describe the new interface.

cwayne18 added some commits Jul 19, 2016

Contributor

zyga commented Jul 21, 2016

Looks good to me. Let's merge it after Jamie asks it.

interfaces/builtin/hardware_observe.go
+#include <abstractions/base>
+
+/etc/udev/udev.conf r,
+@{PROC}/*/stat r,
@jdstrand

jdstrand Jul 25, 2016

Contributor

These are already in the default template.

interfaces/builtin/hardware_observe.go
+/etc/udev/udev.conf r,
+@{PROC}/*/stat r,
+/run/udev/data/* r,
+/sys/bus/ r,
@jdstrand

jdstrand Jul 25, 2016

Contributor

So is this.

interfaces/builtin/hardware_observe.go
+/run/udev/data/* r,
+/sys/bus/ r,
+/sys/bus/**/ r,
+/sys/class/ r,
@jdstrand

jdstrand Jul 25, 2016

Contributor

And this.

interfaces/builtin/hardware_observe.go
+/var/lib/usbutils/usb.ids r,
+/sys/firmware/dmi/tables/DMI r,
+/sys/firmware/dmi/tables/smbios_entry_point r,
+`
@jdstrand

jdstrand Jul 25, 2016

Contributor

I suggest you clean this up to be:

#include <abstractions/base>

# files in /sys pertaining to hardware
/sys/{block,bus,class,devices}/{,**} r,

# USB IDs
/var/lib/usbutils/usb.ids r,

# DMI tables
/sys/firmware/dmi/tables/DMI r,
/sys/firmware/dmi/tables/smbios_entry_point r,
interfaces/builtin/hardware_observe.go
+/sys/class/ r,
+/sys/class/*/ r,
+/sys/devices/** r,
+@{PROC}/*/mountinfo r,
@jdstrand

jdstrand Jul 25, 2016

Contributor

This is already in mount-observe and shouldn't be here too.

interfaces/builtin/hardware_observe.go
+/sys/class/*/ r,
+/sys/devices/** r,
+@{PROC}/*/mountinfo r,
+@{PROC}/swaps r,
@jdstrand

jdstrand Jul 25, 2016

Contributor

This should be in mount-observe but is currently not. I'll do a PR for that.

interfaces/builtin/hardware_observe.go
+/sys/block/ r,
+/sys/devices/** r,
+/dev/bus/usb/ r,
+/dev/bus/usb/** r,
@jdstrand

jdstrand Jul 25, 2016

Contributor

These are tricky. Read access is potentially more than observe for these files. Reading https://www.kernel.org/doc/Documentation/hid/hiddev.txt I think a /dev/bus/usb/hiddev* r, rule would be ok, perhaps with an additional seccomp arg filtering on ioctl. You used /dev/bus/usb/** r, though, why?

@cwayne18

cwayne18 Jul 25, 2016

Contributor

@jdstrand so the context for this is basically checkbox pulling in device info via lsusb, I got this by running aa-genprof for lsusb, if you think /dev/bus/usb/hiddev* would be better, I could try that out, though I'd have no idea how to do the additional seccomp filtering, do we have any docs for that?

Contributor

jdstrand commented Jul 25, 2016

@cwayne18 - can you comment on whether or not we should allow all ioctls in https://www.kernel.org/doc/Documentation/hid/hiddev.txt or a subset?

interfaces/builtin/hardware_observe.go
+# files in /sys pertaining to hardware
+/sys/{block,bus,class,devices}/{,**} r,
+
+# USB IDs
/var/lib/usbutils/usb.ids r,
@jdstrand

jdstrand Jul 25, 2016

Contributor

Thanks for the cleanup! It just occurred to me that /var/lib/usbutils/usb.ids isn't going to exist on an all-snaps image or within the runtime environment of the snap so I think it doesn't make sense to have this rule?

@cwayne18

cwayne18 Jul 25, 2016

Contributor

Ah, you're right, and in fact we can use a usb.ids from within the snap as it is, I'll remove this line

interfaces/builtin/hardware_observe.go
+# from the system. This is reserved for OS snap.
+# Usage: reserved
+
+#include <abstractions/base>
@jdstrand

jdstrand Jul 25, 2016

Contributor

I missed this before-- please drop the base abstraction-- it is part of the default template (see interfaces/apparmor/template.go).

interfaces/builtin/hardware_observe.go
+// http://bazaar.launchpad.net/~ubuntu-security/ubuntu-core-security/trunk/view/head:/data/apparmor/policygroups/ubuntu-core/16.04/log-observe
+const hardwareObserveConnectedPlugAppArmor = `
+# Description: This interface allows for getting hardware information
+# from the system. This is reserved for OS snap.
@jdstrand

jdstrand Jul 25, 2016

Contributor

Please change "This is reserved for the OS snap" to "this is reserved because it allows reading potentially sensitive information".

cwayne18 added some commits Jul 25, 2016

Contributor

jdstrand commented Jul 25, 2016

Security policy LGTM after the recent changes. +1

Contributor

zyga commented Jul 26, 2016

LGTM then. Thank you for the in-depth review @jdstrand

@zyga zyga merged commit 4d51760 into snapcore:master Jul 26, 2016

3 checks passed

Integration tests Success
Details
autopkgtest Success
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment