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

interfaces/apparmor: allow access to core snap #2413

Merged
merged 4 commits into from Dec 12, 2016

Conversation

zyga
Copy link
Collaborator

@zyga zyga commented Dec 6, 2016

This patch changes the default apparmor template to allow read access to
the core snap (at any revision). This is required to allow classic snaps
that use the dynamic linker or libraries when they were forcibly
confined with jailmode.

Signed-off-by: Zygmunt Krynicki zygmunt.krynicki@canonical.com

This patch changes the default apparmor template to allow read access to
the core snap (at any revision). This is required to allow classic snaps
that use the dynamic linker or libraries when they were forcibly
confined with jailmode.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
@zyga zyga added the ⚠ Critical High-priority stuff (e.g. to fix master) label Dec 6, 2016
@jdstrand
Copy link

jdstrand commented Dec 6, 2016

Based on conversations with @zyga, jailmode with --classic has been defined as strict mode plus read-only access to all of the core snap. As such, please:

  • document the confinement story somewhere
  • remove this rule from the default template and add it conditionally as a snippet 'if isClassic and isJailmode'

This makes the intent of the default template clear that it is (still) a subset of core and makes policy audits clearer.

@zyga
Copy link
Collaborator Author

zyga commented Dec 6, 2016

Thanks for the review @jdstrand. I'll document the whole confinement story on the wiki. As for the extra core rule, I can do that via a fake snippet. I'll ping you for a second look.

@jdstrand
Copy link

jdstrand commented Dec 6, 2016

Thanks! I think it will also help us future-proof a bit-- I have a suspicion that we'll want to add another rule or two for classic that may not be appropriate for regular strict mode and this will facilitate that.

This patch tweaks earlier code so that when both jailmode and classic
confinement is used a special snippet is internally added. This snippet
provides read only access to the core snap so that the dynamic linker
and runtime libraries can be accessed.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Copy link
Contributor

@niemeyer niemeyer left a comment

Choose a reason for hiding this comment

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

Per our discussion in the channel, LGTM as long as this is opened up only if --jailmode is actually used. We currently don't allow normal snaps to read all of core in its usual mount point, so it wouldn't make a lot of sense to allow them to read it only in an alternative path in general (either it's okay to read, or it's not).

@niemeyer
Copy link
Contributor

Sorry, to be clear, --jailmode and --classic, not just --jailmode.

// Add a special internal snippet for snaps using classic confinement
// and jailmode together. This snippet provides access to the core snap
// so that the dynamic linker and shared libraries can be used.
tagSnippets = append(tagSnippets, classicJailmodeSnippet)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it'd make more sense to have this before the custom snippets.

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 added comment from feedback

} else {
tagSnippets = snippets[securityTag]
}
return bytes.Join(tagSnippets, []byte("\n"))

Choose a reason for hiding this comment

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

Thank you for this addition. @niemeyer was right to point out that we only want to give read access to the core snap when using --classic with --jailmode (thanks for that!). With strict, we don't want this rule. With just --classic, we don't need this rule. With --devmode plus --jailmode, we don't want this rule. Only with --classic plus --jailmode do we need it.

LGTM but please add this comment above 'if opts.Classic && opts.JailMode {':

# Only add the classicJailmodeSnippet when using --classic plus --jailmode. Why?
# - normal strict mode shouldn't have it since we don't want to subvert the default
#   template
# - --devmode with or without --jailmode shouldn't have it since it wouldn't
#   accurately represent complain-mode strict
# - --classic without --jailmode doesn't need it since it uses different (non-strict)
#   policy
# - --classic with --jailmode is defined as strict policy plus read-only access to the
#   core snap

@zyga zyga merged commit 8ea03cb into snapcore:master Dec 12, 2016
@zyga zyga deleted the core-snap-access branch August 22, 2017 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚠ Critical High-priority stuff (e.g. to fix master)
Projects
None yet
3 participants