create mir interface #1299

Merged
merged 56 commits into from Aug 12, 2016

Conversation

Projects
None yet
9 participants

first cut at mir interface, i tested this locally based on the latest snapd & this wiki for the mir aspect https://developer.ubuntu.com/en/snappy/guides/mir-snaps/

Contributor

snappy-m-o commented Jun 9, 2016

Can one of the admins verify this patch?

Contributor

snappy-m-o commented Jun 9, 2016

Can one of the admins verify this patch?

Contributor

snappy-m-o commented Jun 9, 2016

Can one of the admins verify this patch?

Member

elopio commented Jun 9, 2016

@kgunn can you please document your test in integration-tests/manual-tests.md ?

interfaces/builtin/all.go
@@ -29,6 +29,7 @@ var allInterfaces = []interfaces.Interface{
&LocationControlInterface{},
&LocationObserveInterface{},
&NetworkManagerInterface{},
+ &MirInterface{},
@zyga

zyga Jun 9, 2016

Contributor

run go fmt on all the files you've changed

interfaces/builtin/mir.go
+/run/udev/data/* r,
+/run/udev/** rw,
+
+ptrace peer=**,
@zyga

zyga Jun 9, 2016

Contributor

mir needs to ptrace?

@jdstrand

jdstrand Jun 9, 2016

Contributor

If mir server needs ptrace, it should be more fine-grained than this and only ptrace for connected clients. Please use something like this in mirConnectedPlugAppArmor:
ptrace (tracedby) peer=###SLOT_SECURITY_TAGS###,

Then the mirConnectedSlotAppArmor would have:
ptrace (trace) peer=###PLUG_SECURITY_TAGS###,

The above assumes you need 'trace' Can you paste the apparmor denial that prompted this rule?

@kgunnfront

kgunnfront Jun 13, 2016

removed ptrace references, i know we add these long ago, but appearantly they are not needed

interfaces/builtin/mir.go
+capability sys_admin,
+
+unix (receive, send) type=seqpacket addr=none,
+/tmp/mir_socket rw,
@zyga

zyga Jun 9, 2016

Contributor

Why is the socket in /tmp and not in /run? /tmp is private and per-app and won't work with snaps

@kgunnfront

kgunnfront Jun 13, 2016

this was an old artifcat, removed /tmp references

interfaces/builtin/mir.go
+unix (receive, send) type=seqpacket addr=none,
+/tmp/mir_socket rw,
+/dev/dri/card0 rw,
+/dev/shm/\#* rw,
@zyga

zyga Jun 9, 2016

Contributor

What does \# mean there?

Could mir use shm entries that follow /dev/shm/snap.$SNAP_NAME?

@kgunnfront

kgunnfront Jun 13, 2016

in this instance the # is actually the # in part of the directory name. for instance if i remove this line, I get the denial in the following way
apparmor="DENIED" operation="open" profile="snap.mir-server.mir-server" name="/dev/shm/#3" pid=5217 comm="mir-server" requested_mask="wr" denied_mask="wr" fsuid=0 ouid=0

also, mir is all server side allocated, so not sure the snap.$SNAP_NAME would work

interfaces/builtin/mir.go
+/sbin/killall5 ixr,
+/usr/bin/expr ixr,
+/usr/bin/chmod ixr,
+/bin/chmod ixr,
@zyga

zyga Jun 9, 2016

Contributor

Are all of those commands guaranteed to exist in the image? Should mir ship those tools internally?

@jdstrand

jdstrand Jun 9, 2016

Contributor

All of these commands can be removed. They are in the default policy (interfaces/apparmor/template.go).

interfaces/builtin/mir.go
+capability sys_ptrace,
+
+network netlink raw,
+/run/mir_socket rw,
@zyga

zyga Jun 9, 2016

Contributor

So is it /tmp/mir_socket or /run/mir_socket?

@kgunnfront

kgunnfront Jun 16, 2016

only run, corrected

interfaces/builtin/mir.go
+mmap2
+mprotect
+
+# LP: #1448184 - these aren't currently mediated by AppArmor. Deny for now
@zyga

zyga Jun 9, 2016

Contributor

Why are those commented out entries here? Is mir using them?

interfaces/builtin/mir.go
+capability sys_admin,
+
+unix (receive, send) type=seqpacket addr=none,
+/tmp/mir_socket rw,
@zyga

zyga Jun 9, 2016

Contributor

This won't work, you have you use /run as each process gets a private /tmp that is invisible to anyone else.

@kgunnfront

kgunnfront Jun 15, 2016

yep, removed /tmp for /run

interfaces/builtin/mir.go
+unix (receive, send) type=seqpacket addr=none,
+/tmp/mir_socket rw,
+/dev/dri/card0 rw,
+/dev/shm/\#* rw,
@zyga

zyga Jun 9, 2016

Contributor

Can this be made so that it is specific to the snap? Ideally mir would create buffers here that cannot be opened by any other process except the one that mir is talking to (so client A cannot look at shared objects of client B).

interfaces/builtin/mir.go
+/run/udev/data/* r,
+/run/udev/** rw,
+
+ptrace peer=**,
@zyga

zyga Jun 9, 2016

Contributor

Does this mean the mir clients need ptrace?

interfaces/builtin/mir.go
+/run/udev/** rw,
+
+ptrace peer=**,
+/bin/sleep mrix,
@zyga

zyga Jun 9, 2016

Contributor

Mir cliends should not run those applications. Can you expand on why they are here.

@kgunnfront

kgunnfront Jun 15, 2016

was an artifact, since removed

interfaces/builtin/mir.go
+/proc/*/cmdline r,
+/sys/bus/ r,
+/sys/class/ r,
+/sys/class/input/ r,
@zyga

zyga Jun 9, 2016

Contributor

Why do mir clients needs to read this? It seems like something mir server does

@jdstrand

jdstrand Jun 9, 2016

Contributor

@zyga - I'm reading this as part of mirPermanentSlotAppArmor, so should just be the server.

@kgunnfront

kgunnfront Jun 13, 2016

correct, i'm only focused on mir-server at the moment

interfaces/builtin/mir.go
+/sys/class/drm/ r,
+/etc/udev/udev.conf r,
+capability sys_ptrace,
+capability chown,
@zyga

zyga Jun 9, 2016

Contributor

Why does mir client need to chown files?

@jdstrand

jdstrand Jun 9, 2016

Contributor

Again, this is the server, but I can't recall why the server needs to chown either. Can you comment in the code with a 'Note:'.

@kgunnfront

kgunnfront Jun 16, 2016

artifact, i was able to remove

interfaces/builtin/mir.go
+capability sys_ptrace,
+capability chown,
+capability fowner,
+capability sys_ptrace,
@zyga

zyga Jun 9, 2016

Contributor

Same question as ptrace above

@jdstrand

jdstrand Jun 9, 2016

Contributor

You repeated this rule. Please remove.

interfaces/builtin/mir.go
+
+var mirConnectedPlugSecComp = []byte(`
+# Description: Allow operating as the mir service. Reserved because this
+# gives privileged access to the system.
@zyga

zyga Jun 9, 2016

Contributor

To be clear this should be different. The mir slot is restricted and can be only used by mir itself. The mir plug should not be restricted because mir is supposed to be more secure than X11.

@jdstrand

jdstrand Jun 9, 2016

Contributor

In addition to what zyga said, this should have something in it besides the comment. It should contain something along the lines of what was in mir_client for seccomp on 15.04.

@kgunnfront

kgunnfront Jun 16, 2016

removed, in the final efforts, not needed

+ return "mir"
+}
+
+func (iface *MirInterface) PermanentPlugSnippet(
@zyga

zyga Jun 9, 2016

Contributor

Please run go fmt on this file.

@kgunnfront

kgunnfront Jun 15, 2016

ran go fmt on all files

interfaces/builtin/mir.go
+ slot *interfaces.Slot,
+ securitySystem interfaces.SecuritySystem) ([]byte, error) {
+ switch securitySystem {
+ case interfaces.SecurityAppArmor:
@zyga

zyga Jun 9, 2016

Contributor

Why aren't you returning the snippets if you have defined above?

@jdstrand

jdstrand Jun 9, 2016

Contributor

Ah, this is probably why Kevin had the policy in both places and had trouble. @kgunn, anywhere you defined AppArmor or Seccomp above you need to return non-nil in the corresponding snippets. So, this is ConnectedPlugSnippet, and you provided mirConnectedPlugAppArmor and mirConnectedPlugSeccomp above, so interfaces.SecurityAppArmor and interfaces.SecuritySeComp should return non-nil here.

@kgunnfront

kgunnfront Jun 16, 2016

correct, after lots and lots of experimenting - returning the seccomp and aa profiles for mir server on PermanentPlugSnippet is what worked, returning on any other (PermSlotSnippet, ConnectedSlotSnippet, ConnectedPlugSnippet did not work and i tested each). Which honestly was not what i thought would occur - I believed that for Mir server it should have reported on PermanentSlot

@kgunnfront

kgunnfront Aug 4, 2016

ok, this was related to me mistakenly using wrong label in yaml - so this is now correct

+ }
+}
+
+func (iface *MirInterface) PermanentSlotSnippet(
@zyga

zyga Jun 9, 2016

Contributor

Ditto, return the permanent snippets defined above here please.

+ return nil
+}
+
+func (iface *MirInterface) AutoConnect() bool {
@zyga

zyga Jun 9, 2016

Contributor

IMHO mir should auto connect.

@jdstrand

jdstrand Jun 9, 2016

Contributor

We've said the slot side should autoconnect, yes, and the plugs side of Mir is supposed to be safe for anyone, so yes, autoconnect.

@kgunnfront

kgunnfront Jun 16, 2016

changed autoconnect to true

@@ -0,0 +1,95 @@
+// -*- Mode: Go; indent-tabs-mode: t -*-
+
@zyga

zyga Jun 9, 2016

Contributor

I'll skip reviewing this until the mir.go itself is updated.

@kgunnfront

kgunnfront Jun 16, 2016

ok, zyga/jamie - i think it's probably ready for another round, spend large amount of today/y'day cleaning up

@zyga zyga added the Reviewed label Jun 9, 2016

Contributor

zyga commented Jun 9, 2016

Please fix the mentioned bits and answer the few questions I've asked. Thank you for submitting this, one step closer to not having to use X11

interfaces/builtin/mir.go
+
+unix (receive, send) type=seqpacket addr=none,
+/tmp/mir_socket rw,
+/dev/dri/card0 rw,
@jdstrand

jdstrand Jun 9, 2016

Contributor

This gets back to the opengl interface.

interfaces/builtin/mir.go
+capability sys_tty_config,
+capability sys_admin,
+
+unix (receive, send) type=seqpacket addr=none,
@jdstrand

jdstrand Jun 9, 2016

Contributor

IIRC, this was going to be investigated and, again IIRC, @vosst said that Mir shouldn't be using these. Can someone confirm? If we need it, we should have a unix peer=(label=...) rule, likely one for slot and plug side. Can you post the denial that prompted this rule?

@kgunnfront

kgunnfront Jun 16, 2016

commenting out "unix (receive, send) type=seqpacket addr=none,"
results in the following upon trying to run the client app

Jun 16 20:56:11 localhost ubuntu-core-launcher[4427]: Loading module: 'libubuntu_application_api_desktop_mirclient.so.3.0.0'
Jun 16 20:56:12 localhost kernel: [ 3126.446100] audit: type=1400 audit(1466110572.256:20): apparmor="DENIED" operation="open" profile="snap.mir-client.client-start" name="/usr/share/applications/" pid=4429 comm="clocks" requested_mask="r" denied_mask="r" fsuid=0 ouid=0

@jdstrand

jdstrand Jul 8, 2016

Contributor

That denial is for something unrelated and is a noisy denial that shouldn't affect the app's functionality. Please leave out the seqpacket line.

@jdstrand

jdstrand Aug 2, 2016

Contributor

Ping regarding: my question regarding 'unix (receive, send) type=seqpacket addr=none,'

interfaces/builtin/mir.go
+# Usage: reserved
+
+
+capability dac_override,
@jdstrand

jdstrand Jun 9, 2016

Contributor

Why is this needed?

@kgunnfront

kgunnfront Jun 16, 2016

without it the following occurs on server launch

Jun 16 21:19:13 localhost ./devtools.snapd[5034]: taskrunner.go:238: DEBUG: Running task 100 on Do: Make snap "mir-server" available to the system
Jun 16 21:19:13 localhost systemd[1]: Reloading.
Jun 16 21:19:14 localhost systemd[1]: snapd.refresh.timer: Adding 1h 9min 46.277746s random time.
Jun 16 21:19:14 localhost systemd[1]: Reloading.
Jun 16 21:19:14 localhost systemd[1]: snapd.refresh.timer: Adding 9min 58.505083s random time.
Jun 16 21:19:14 localhost systemd[1]: Started Service for snap application mir-server.mir-server.
Jun 16 21:19:14 localhost ./devtools.snapd[5034]: daemon.go:181: DEBUG: uid=0;@ GET /v2/snaps 1.126997ms 200
Jun 16 21:19:14 localhost ubuntu-core-launcher[5138]: Mir server snap started
Jun 16 21:19:14 localhost ubuntu-core-launcher[5138]: [2016-06-16 21:19:14.438531] mirplatform: Found graphics driver: mir:mesa-kms (version 0.23.0)
Jun 16 21:19:14 localhost ubuntu-core-launcher[5138]: [2016-06-16 21:19:14.455655] mirplatform: Found graphics driver: mir:mesa-x11 (version 0.23.0)
Jun 16 21:19:14 localhost ubuntu-core-launcher[5138]: [2016-06-16 21:19:14.460754] mirserver: Starting
Jun 16 21:19:14 localhost ubuntu-core-launcher[5138]: [2016-06-16 21:19:14.461495] mircommon: Loading modules from: /snap/mir-server/x1/usr/lib/x86_64-linux-gnu/mir/server-platform
Jun 16 21:19:14 localhost ubuntu-core-launcher[5138]: [2016-06-16 21:19:14.461990] mircommon: Loading module: /snap/mir-server/x1/usr/lib/x86_64-linux-gnu/mir/server-platform/graphics-mesa-kms.so.9
Jun 16 21:19:14 localhost ubuntu-core-launcher[5138]: [2016-06-16 21:19:14.462408] mircommon: Loading module: /snap/mir-server/x1/usr/lib/x86_64-linux-gnu/mir/server-platform/server-mesa-x11.so.9
Jun 16 21:19:14 localhost ubuntu-core-launcher[5138]: [2016-06-16 21:19:14.463333] mircommon: Loading module: /snap/mir-server/x1/usr/lib/x86_64-linux-gnu/mir/server-platform/input-evdev.so.5
Jun 16 21:19:14 localhost ubuntu-core-launcher[5138]: [2016-06-16 21:19:14.465184] mirplatform: Found graphics driver: mir:mesa-kms (version 0.23.0)
Jun 16 21:19:14 localhost ubuntu-core-launcher[5138]: [2016-06-16 21:19:14.465662] mirplatform: Found graphics driver: mir:mesa-x11 (version 0.23.0)
Jun 16 21:19:14 localhost ubuntu-core-launcher[5138]: [2016-06-16 21:19:14.466394] mirserver: Selected driver: mir:mesa-kms (version 0.23.0)
Jun 16 21:19:14 localhost kernel: [ 4508.651864] audit: type=1400 audit(1466111954.459:24): apparmor="DENIED" operation="capable" profile="snap.mir-server.mir-server" pid=5140 comm="mir-server" capability=1 capname="dac_override"
Jun 16 21:19:14 localhost kernel: [ 4508.651871] audit: type=1400 audit(1466111954.459:25): apparmor="DENIED" operation="capable" profile="snap.mir-server.mir-server" pid=5140 comm="mir-server" capability=2 capname="dac_read_search"

interfaces/builtin/mir.go
+
+capability dac_override,
+capability sys_tty_config,
+capability sys_admin,
@jdstrand

jdstrand Jun 9, 2016

Contributor

I recall this was needed but I'm annoyed it is....

@kgunnfront

kgunnfront Jun 16, 2016

i verified during clean up it's still needed.

interfaces/builtin/mir.go
+/dev/shm/\#* rw,
+
+/sys/devices/**/uevent rw,
+/sys/devices/**/ r,
@jdstrand

jdstrand Jun 9, 2016

Contributor

This is very broad and gets back to the udev querying I've detailed in the opengl interface.

@kgunnfront

kgunnfront Jun 16, 2016

I've done some clean up there, /sys/devices now removed

interfaces/builtin/mir.go
+
+/sys/devices/**/uevent rw,
+/sys/devices/**/ r,
+/dev/input/* rw,
@jdstrand

jdstrand Jun 9, 2016

Contributor

Can you add a comment: Note: this allows reading and inserting all input events

interfaces/builtin/mir.go
+/dev/tty* wr,
+/run/udev/data/* r,
+/run/udev/** rw,
+
@jdstrand

jdstrand Jun 9, 2016

Contributor

These udev get back to the udev querying as detailed in the opengl interface.

interfaces/builtin/mir.go
+/usr/bin/expr ixr,
+/usr/bin/chmod ixr,
+/bin/chmod ixr,
+/proc/ r,
@jdstrand

jdstrand Jun 9, 2016

Contributor

Please use: @{PROC}/ r,

interfaces/builtin/mir.go
+/usr/bin/chmod ixr,
+/bin/chmod ixr,
+/proc/ r,
+/proc/*/stat r,
@jdstrand

jdstrand Jun 9, 2016

Contributor

This is in the default policy, please remove.

interfaces/builtin/mir.go
+/bin/chmod ixr,
+/proc/ r,
+/proc/*/stat r,
+/proc/*/cmdline r,
@jdstrand

jdstrand Jun 9, 2016

Contributor

This is in the default policy, please remove.

interfaces/builtin/mir.go
+/dev/dri/card0 rw,
+/dev/shm/\#* rw,
+
+/sys/devices/**/uevent rw,
@jdstrand

jdstrand Jun 9, 2016

Contributor

'r' is allowed by the default policy. You actually need 'w' to /sys/devices? Why?

interfaces/builtin/mir.go
+/sys/class/ r,
+/sys/class/input/ r,
+/sys/class/drm/ r,
+/etc/udev/udev.conf r,
@jdstrand

jdstrand Jun 9, 2016

Contributor

This is in the default policy. Please remove.

interfaces/builtin/mir.go
+/sys/bus/ r,
+/sys/class/ r,
+/sys/class/input/ r,
+/sys/class/drm/ r,
@jdstrand

jdstrand Jun 9, 2016

Contributor

This gets back to opengl interface.

@kgunnfront

kgunnfront Jun 16, 2016

uh, much of this since removed

interfaces/builtin/mir.go
+/sys/class/input/ r,
+/sys/class/drm/ r,
+/etc/udev/udev.conf r,
+capability sys_ptrace,
@jdstrand

jdstrand Jun 9, 2016

Contributor

Please put this next to the ptrace rule.

interfaces/builtin/mir.go
+pwrite
+pwrite64
+pwritev
+`)
@jdstrand

jdstrand Jun 9, 2016

Contributor

This looks like the default policy in interfaces/seccomp/template.go. Can you list here only what isn't included there?

@kgunnfront

kgunnfront Jun 16, 2016

went through fine tooth and cleaned up

interfaces/builtin/mir.go
+capability chown,
+capability fowner,
+capability sys_ptrace,
+`)
@jdstrand

jdstrand Jun 9, 2016

Contributor

The policy for mirConnectedPlugAppArmor is wrong. It should contain what the client needs, but this is all the privileged policy of the server. This should contain something along the lines of what was in mir_client for apparmor on 15.04.

@kgunnfront

kgunnfront Jun 16, 2016

since cleaned up

Contributor

snappy-m-o commented Jun 13, 2016

Can one of the admins verify this patch?

Contributor

snappy-m-o commented Jun 13, 2016

Can one of the admins verify this patch?

Contributor

snappy-m-o commented Jun 13, 2016

Can one of the admins verify this patch?

dependencies.tsv
@@ -8,7 +8,6 @@ github.com/jessevdk/go-flags git 6b9493b3cb60367edd942144879646604089e3f7 2016-0
github.com/kr/pty git 05017fcccf23c823bfdea560dcc958a136e54fb7 2014-12-17T21:19:37Z
github.com/mvo5/goconfigparser git 26426272dda20cc76aa1fa44286dc743d2972fe8 2015-02-12T09:37:50Z
github.com/mvo5/uboot-go git 361f6ebcbb54f389d15dc9faefa000e996ba3e37 2015-07-22T06:53:46Z
-github.com/peterh/liner git 1bb0d1c1a25ed393d8feb09bab039b2b1b1fbced 2015-04-02T04:04:07Z
@jdstrand

jdstrand Aug 2, 2016

Contributor

This seems like an odd change for your PR.

@kgunnfront

kgunnfront Aug 4, 2016

I've since reverted and pushed correction

interfaces/builtin/all.go
@@ -32,6 +32,7 @@ var allInterfaces = []interfaces.Interface{
&ModemManagerInterface{},
&MprisInterface{},
&NetworkManagerInterface{},
+ &MirInterface{},
@jdstrand

jdstrand Aug 2, 2016

Contributor

Can you put this in alphabetically like you did in all_test.go?

interfaces/builtin/mir.go
+/dev/dri/card0 rw,
+/dev/shm/\#* rw,
+/dev/tty* wr,
+/run/udev/data/* r,
@jdstrand

jdstrand Aug 2, 2016

Contributor

I suspect this can be limited based on https://www.kernel.org/doc/Documentation/devices.txt. What files is it accessing in /run/udev/data/?

@kgunnfront

kgunnfront Aug 4, 2016

When I remove /run/udev/data/* r, the server will receive these denials

Aug 4 20:19:13 localhost ubuntu-core-launcher[1499]: [2016-08-04 20:19:13.694297] mirplatform: Found graphics driver: mir:mesa-x11 (version 0.23.5)
Aug 4 20:19:13 localhost ubuntu-core-launcher[1499]: Unknown command line options: --vt 1
Aug 4 20:19:13 localhost kernel: [ 589.117731] audit: type=1400 audit(1470341953.690:15): apparmor="DENIED" operation="open" profile="snap.mir-server.mir-server" name="/run/udev/data/+drm:card0-Virtual-1" pid=1501 comm="mir-server" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Aug 4 20:19:13 localhost kernel: [ 589.117859] audit: type=1400 audit(1470341953.690:16): apparmor="DENIED" operation="open" profile="snap.mir-server.mir-server" name="/run/udev/data/+drm:card0-Virtual-2" pid=1501 comm="mir-server" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Aug 4 20:19:13 localhost kernel: [ 589.117948] audit: type=1400 audit(1470341953.690:17): apparmor="DENIED" operation="open" profile="snap.mir-server.mir-server" name="/run/udev/data/+drm:card0-Virtual-3" pid=1501 comm="mir-server" requested_mask="r" denied_mask="r" fsuid=0 ouid=0

So is there some alternative?
note, i already have /dev/dri/card0 rw, in the list

@jdstrand

jdstrand Aug 4, 2016

Contributor

You should probably just 'plugs: [ opengl ]' in the server, though I think you'll need to change snap/implicit.go to move opengl out of implicitClassicSlots and into implicitSlots. I think you'd also want to move /dev/dri/card0 rw, into opengl too. Not sure why it isn't there now....

If this is undesirable, can copy this from the opengl interface:

  # FIXME: this is an information leak and snapd should instead query udev for
  # the specific accesses associated with the above devices.
  /sys/bus/pci/devices/** r,
  /run/udev/data/+drm:card* r,
  /run/udev/data/+pci:[0-9]* r,

  # FIXME: for each device in /dev that this policy references, lookup the
  # device type, major and minor and create rules of this form:
  # /run/udev/data/<type><major>:<minor> r,
  # For now, allow 'c'haracter devices and 'b'lock devices based on
  # https://www.kernel.org/doc/Documentation/devices.txt
  /run/udev/data/c226:[0-9]* r,  # 226 drm
@jdstrand

jdstrand Aug 8, 2016

Contributor

@niemeyer mentioned this is ready for re-review.

@kgunn - please respond to my questions regarding opengrl, /deg/dri/card0 and /run/udev/data

@kgunnfront

kgunnfront Aug 9, 2016

OK, I rearrange to rely on the opengl i/f for the relevant paths.
I also made opengl part of implicitSlots

interfaces/builtin/mir.go
+
+/usr/share/applications/ r,
+/run/mir_socket rw,
+/run/user/*/mir_socket rw,
@jdstrand

jdstrand Aug 2, 2016

Contributor

Please use this instead: /run/user/[0-9]*/mir_socket rw,

interfaces/builtin/mir.go
+# Description: Permit clients to use Mir
+# Usage: reserver
+
+/usr/share/applications/ r,
@jdstrand

jdstrand Aug 2, 2016

Contributor

This is a bit weird, but I guess it is ok on the slot side.

@kgunnfront

kgunnfront Aug 4, 2016

removed actually

interfaces/builtin/mir.go
+getsockopt
+recvmsg
+sendmsg
+
@jdstrand

jdstrand Aug 2, 2016

Contributor

Please remove this empty line.

@kgunnfront

kgunnfront Aug 4, 2016

removed empty line

interfaces/builtin/mir.go
+/run/user/*/mir_socket rw,
+unix (send, receive) peer=(label=###PLUG_SECURITY_TAGS###)
+
+`)
@jdstrand

jdstrand Aug 2, 2016

Contributor

This is a bit broad. What is it for, anonymous sockets? Also, please remove the empty line.

@kgunnfront

kgunnfront Aug 4, 2016

so for the kiosk style server, it uses /run/mir_socket
and empty line removed

interfaces/builtin/mir.go
+/usr/share/applications/ r,
+/run/mir_socket rw,
+/run/user/*/mir_socket rw,
+unix (send, receive) peer=(label=###SLOT_SECURITY_TAGS###)
@jdstrand

jdstrand Aug 2, 2016

Contributor

This is also a bit broad. What is it for, anonymous sockets?

@kgunnfront

kgunnfront Aug 4, 2016

same as before, /run/mir_socket is used by the kiosk style server

interfaces/builtin/mir.go
+# Description: Permit clients to use Mir
+# Usage: reserver
+
+/usr/share/applications/ r,
@jdstrand

jdstrand Aug 2, 2016

Contributor

This is weird-- why would the client need to look in /usr/share/applications/ for connecting to mir?

@kgunnfront

kgunnfront Aug 4, 2016

I honestly do not know. I just know I get the denial.

interfaces/builtin/mir.go
+
+var mirConnectedPlugAppArmor = []byte(`
+# Description: Permit clients to use Mir
+# Usage: reserver
@jdstrand

jdstrand Aug 2, 2016

Contributor

The connected plug should actually be 'common'.

@kgunnfront

kgunnfront Aug 4, 2016

could you elaborate on what you mean here ?

interfaces/builtin/mir.go
+
+capability dac_override,
+capability sys_tty_config,
+capability sys_admin,
@jdstrand

jdstrand Aug 2, 2016

Contributor

A description of why these capabilities are needed would be ideal.

@kgunnfront

kgunnfront Aug 5, 2016

add a note for the tty cap
i was able to remove dac_override and sys_admin

interfaces/builtin/mir.go
+
+var mirConnectedSlotAppArmor = []byte(`
+# Description: Permit clients to use Mir
+# Usage: reserver
@jdstrand

jdstrand Aug 2, 2016

Contributor

Typo: reserved

interfaces/builtin/mir.go
+
+var mirConnectedPlugSecComp = []byte(`
+# Description: Permit clients to use Mir
+# Usage: reserver
@jdstrand

jdstrand Aug 2, 2016

Contributor

The connected plug should be 'common'.

@kgunnfront

kgunnfront Aug 4, 2016

again, some more context/description would be helpful

@jdstrand

jdstrand Aug 5, 2016

Contributor

You have "# Usage: reserver" (mispelled) for mirConnectedPlugSecComp and mirConnectedPlugAppArmor. This should be "# Usage: common"

interfaces/builtin/mir.go
+ plug *interfaces.Plug,
+ securitySystem interfaces.SecuritySystem) ([]byte, error) {
+ switch securitySystem {
+ case interfaces.SecurityAppArmor, interfaces.SecuritySecComp,
@jdstrand

jdstrand Aug 2, 2016

Contributor

You need go fmt on the files again. This case statement is indented too much.

Contributor

jdstrand commented Aug 2, 2016

Thanks for the updates! This is getting really close in terms of security policy generation and the policy itself. Please see my comments from a few minutes ago.

@pedronis pedronis removed the Reviewed label Aug 2, 2016

Contributor

niemeyer commented Aug 4, 2016

Please respond to the points individually so we can track what has been done and what is still pending.

Marking as Reviewed.

@niemeyer niemeyer added the Reviewed label Aug 4, 2016

Contributor

niemeyer commented Aug 7, 2016

@jdstrand This is ready for a re-review I think.

interfaces/builtin/mir.go
+# Usage: reserved
+# needed since Mir is the display server, to configure tty devices
+capability sys_tty_config,
+unix (receive, send) type=seqpacket addr=none,
@jdstrand

jdstrand Aug 8, 2016

Contributor

unix (receive, send) type=seqpacket addr=none, should move to mirConnectedSlotAppArmor and be: unix (receive, send) type=seqpacket addr=none peer=(label=###PLUG_SECURITY_TAGS###), then you need to adjust mirConnectedSlotAppArmor to substitute ###PLUG_SECURITY_TAGS### like you do ###SLOT_SECURITY_TAGS### in mirConnectedPlugAppArmor

@jdstrand

jdstrand Aug 8, 2016

Contributor

Actually, I see you already have done that. Can you not just remove unix (receive, send) type=seqpacket addr=none, from mirPermanentSlotAppArmor() altogether?

@kgunnfront

kgunnfront Aug 9, 2016

yep, removed the redundant unix (receive, send) type=seqpacket addr=none, from permanent slot

Contributor

jdstrand commented Aug 8, 2016

@niemeyer - done. Two remaining open questions.

interfaces/builtin/mir.go
+# needed since Mir is the display server, to configure tty devices
+capability sys_tty_config,
+/dev/shm/\#* rw,
+/dev/tty* wr,
@jdstrand

jdstrand Aug 11, 2016

Contributor

For consistency, it would be nice if this was 'rw' instead of 'wr' (makes no difference to the policy).

However, /dev/tty* is, I think, too broad since USB serial devices might be found at /dev/ttyUSB*. Assuming you don't intend for mir to configure USN ttys, can you adjust this to be: /dev/tty[0-9]* rw,

(sorry I didn't notice this before).

@kgunnfront

kgunnfront Aug 11, 2016

limited dev/tty and made it rw

interfaces/builtin/mir.go
+`)
+
+var mirPermanentSlotSecComp = []byte(`
+# Description: Allow operating as the mir service. Reserved because this
@jdstrand

jdstrand Aug 11, 2016

Contributor

"Description: Allow operating as the mir service." - please s/service/server/ so it is consistent with mirPermanentSlotAppArmor.

@kgunnfront

kgunnfront Aug 11, 2016

changed to be consistent

+ snippet, err = s.iface.ConnectedSlotSnippet(s.plug, s.slot, "foo")
+ c.Assert(err, Equals, interfaces.ErrUnknownSecurity)
+ c.Assert(snippet, IsNil)
+}
@jdstrand

jdstrand Aug 11, 2016

Contributor

Can you add an AutoConnect test?

func (s *NetworkInterfaceSuite) TestAutoConnect(c *C) {
    c.Check(s.iface.AutoConnect(), Equals, true)
}
snap/implicit.go
@@ -34,11 +34,13 @@ var implicitSlots = []string{
"hardware-observe",
"locale-control",
"log-observe",
+ "mir",
@jdstrand

jdstrand Aug 11, 2016

Contributor

I think mir should be in implicitClassicSlots, no? On an all snaps system mir is provided as a snap (therefore not needed in implicitSlots) but on a classic system (eg, one with unity8) then mir would be part of the system (that said, there are I think changes that are needed to make this interface work on classic for the unix label rules, but those can be fixed in a later PR). If this is only for kiosks on all-snaps systems (or at least this PR is), perhaps don't have mir be an implicit slot at all.

@kgunnfront

kgunnfront Aug 11, 2016

agreed, simply removed until we know more wrt personal and the future, will work through the classic case next

interfaces/builtin/mir.go
+# needed since Mir is the display server, to configure tty devices
+capability sys_tty_config,
+/dev/shm/\#* rw,
+/dev/tty[0-9] rw,
@jdstrand

jdstrand Aug 11, 2016

Contributor

Whoops, I think github masked the '*' in my last comment. This should be:

/dev/tty[0-9]* rw,
Contributor

jdstrand commented Aug 11, 2016

+1 assuming the tests pass.

Collaborator

mvo5 commented Aug 12, 2016

This looks good now, thank you.

@mvo5 mvo5 merged commit f7178bb into snapcore:master Aug 12, 2016

1 check passed

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