Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/snap-confine: allow content interface mounts #2462

Merged
merged 13 commits into from
Dec 12, 2016

Conversation

zyga
Copy link
Contributor

@zyga zyga commented Dec 12, 2016

This branch fixes writable content sharing, there are two parts to this:

The confinement profile for snap-confine is changed to allow to perform more of the actions
that that the content interface allows to express. This specifically allows $SNAP_DATA,
$SNAP_COMMON and $SNAP to be shared as long as both source and destination share
permissions (can be both read or both written). In addition, a snap developer can choose to share
a naturally writable location in a read only way (e.g. a read-only view of $SNAP_DATA)

The generated apparmor profile is changed to work around Linux Security Modules design where
bind mounting a socket doesn't change how apparmor interprets the path (apparmor still sees
the original path).

Signed-off-by: Zygmunt Krynicki [email protected]

@mvo5
Copy link
Contributor

mvo5 commented Dec 12, 2016

Nice!

mount options=(ro bind) /snap/*/** -> /snap/*/*/**,
mount options=(ro bind) /snap/*/** -> /var/snap/*/*/**,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment above doesn't describe this new rule (only the other two). Please adjust and LGTM

# snaps may directly access the slot implementation's files
# read-only.
/var/snap/%s/%s/** mrkix,
`, slot.Snap.Name, slot.Snap.Revision)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These rules are fine since they only grant the same access to the same files that the bind SecurityMount backend provides, except it allows named sockets to work predictably in the same way.

The 'write' is only needed for named sockets, but thank you for adding the 'read' since it will avoid an inconsistency that may trip people up down the line if people decide to use the slot implementation's path directly.

All that said, the /var/snap/%s/%s used in the AppArmor rule is exactly the same as what mountEntry gives for source, with '/** ...' appended. Please update/use resolveSpecialVariable() so that we have AppArmor rules that precisely match the src mount.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link

@jdstrand jdstrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with minor comment changes.

# snaps may directly access the slot implementation's files. Due
# to a limitation in the kernel's LSM hooks for AF_UNIX, this rule
# is needed for using named sockets within the exported
# directory.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this was reorganized the comment isn't quite right for policy auditors. Please adjust to:

# In addition to the bind mount, add any AppArmor rules so that
# snaps may directly access the slot implementation's files. Due
# to a limitation in the kernel's LSM hooks for AF_UNIX, these
# are needed for using named sockets within the exported
# directory.

fmt.Fprintf(contentSnippet, `
# In addition to the bind mount, add an AppArmor rule so that
# snaps may directly access the slot implementation's files
# read-only.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here:

# In addition to the bind mount, add any AppArmor rules so that
# snaps may directly access the slot implementation's files
# read-only.

@mvo5
Copy link
Contributor

mvo5 commented Dec 12, 2016

👍

@mvo5 mvo5 merged commit 3ffdd59 into canonical:master Dec 12, 2016
@zyga zyga deleted the fix-snap-confine-permissions branch December 12, 2016 22:08
@morphis
Copy link
Contributor

morphis commented Dec 13, 2016

It would be nice to have a spread test for this to ensure the actual use case covered by this (sharing a unix domain socket) works well and doesn't break.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants