overlord/ifacestate: setup seccomp security on startup #2821

Merged
merged 2 commits into from Feb 9, 2017

Conversation

Projects
None yet
4 participants
Contributor

zyga commented Feb 9, 2017

This patch attempts to unbreak the world by automatically refreshing the
seccomp profiles on startp of snapd. Seccomp profiles are not expensive
to compute and don't require compilation or loading.

This lets us fix the problem that surfaced when snapd started generating
a syntax, in the seccomp profile, that only new snap-confine
understands. Because snap-confine does not conceptually re-execute yet
everyone that is on the edge channel is now experiencing problems.

This patch should be applied along the next patch that generates
compatible seccomp profiles, without the new syntax.

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

overlord/ifacestate: setup seccomp security on startup
This patch attempts to unbreak the world by automatically refreshing the
seccomp profiles on startp of snapd. Seccomp profiles are not expensive
to compute and don't require compilation or loading.

This lets us fix the problem that surfaced when snapd started generating
a syntax, in the seccomp profile, that only new snap-confine
understands. Because snap-confine does not conceptually re-execute yet
everyone that is on the edge channel is now experiencing problems.

This patch should be applied along the next patch that generates
compatible seccomp profiles, without the new syntax.

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

@zyga zyga added the Critical label Feb 9, 2017

+ securityBackends := m.repo.Backends()
+
+ // Get all the snap infos
+ snaps, err := snapstate.ActiveInfos(m.state)
@pedronis

pedronis Feb 9, 2017

Contributor

this gives you only active snaps (you need All to get all of them), I know we recently changed enable/disable to remove profiles os inactive ones don't have them, but not sure if it means there is something to do for old inactive stuff

@zyga

zyga Feb 9, 2017

Contributor

For inactive stuff there's nothing to do ATM: first of all profiles are not versioned (just the current revision can exist) and second of all once activated those profiles will get generated.

chipaca approved these changes Feb 9, 2017

lgtm

interfaces/builtin/mount_observe.go
+# FIXME: restore detailed parameter filtering for quota control once
+# snap-confine can read this syntax.
+# See LP:#1662489 for context.
+quotactl
@jdstrand

jdstrand Feb 9, 2017

Contributor

NAK. quotactl was never granted before and this grants more privilege than mount-observe is meant to have.

interfaces/seccomp/template.go
-ioctl - !TIOCSTI
+# FIXME: replace this with the filter of TIOCSTI once snap-confine can read this syntax
+# See LP:#1662489 for context.
+ioctl
@jdstrand

jdstrand Feb 9, 2017

Contributor

This seems like the wrong approach. We will never be able to adjust seccomp policy that requires changes to snap-confine if we wait for 'snap-confine can read this syntax' since a package might be stuck for a long time. What is wrong with the exec'ing snap-confine from core approach?

@zyga

zyga Feb 9, 2017

Contributor

We've discussed this on a hangout so I'll just reply with a quick summary:

  • this is a temporary fix to unbreak the world
  • we will use snap-confine from the core
  • the patch a09abe7 should be reverted as a part of that work
@jdstrand

jdstrand Feb 9, 2017

Contributor

Similar as with quota, can you do this:

# TIOCSTI allows for faking input (man tty_ioctl)
# TODO: this should be scaled back even more
#ioctl - !TIOCSTI
# FIXME: replace this with the filter of TIOCSTI once snap-confine can read this syntax
# See LP:#1662489 for context.
ioctl
@zyga

zyga Feb 9, 2017

Contributor

Done

+ continue
+ }
+ // Refresh security of this snap and backend
+ if err := backend.Setup(snapInfo, opts, m.repo); err != nil {
@jdstrand

jdstrand Feb 9, 2017

Contributor

How atomic is this operation? Since this happens outside of install/refresh/revert it seems possible for a snap to try to start while this is happening. Is there a race here?

@zyga

zyga Feb 9, 2017

Contributor

It runs before anything else can run, during setup of the snapd process.

@jdstrand

jdstrand Feb 9, 2017

Contributor

Ok, but OnClassic, imagine a core refresh comes in at the same time that the user is trying to execute the command who's profile is being refreshed. What will happen?

@zyga

zyga Feb 9, 2017

Contributor

We use atomic rewrite of sorts (move) so we should only see one state.

Few minor changes. As @zyga said, we discussed this with @mvo5. The path forward is land this branch now to unbreak edge, then land #2810 (which should address the FIXMEs in this PR), then decide the next steps.

interfaces/builtin/mount_observe.go
-quotactl Q_XGETQUOTA - - -
-quotactl Q_XGETQSTAT - - -
+# FIXME: restore quotactl with parameter filtering once # snap-confine can read
+this syntax. # See LP:#1662489 for context.
@jdstrand

jdstrand Feb 9, 2017

Contributor

You have invalid syntax here ('this' wrapped around without a comment). Also, rather than removing the rules, can you just comment them out? Eg:

# FIXME: restore quotactl with parameter filtering once snap-confine can read
# this syntax. See LP:#1662489 for context.
#quotactl Q_GETQUOTA - - -
#quotactl Q_GETINFO - - -
#quotactl Q_GETFMT - - -
#quotactl Q_XGETQUOTA - - -
#quotactl Q_XGETQSTAT - - -

@zyga

zyga Feb 9, 2017

Contributor

Yes, thanks

interfaces/seccomp/template.go
-ioctl - !TIOCSTI
+# FIXME: replace this with the filter of TIOCSTI once snap-confine can read this syntax
+# See LP:#1662489 for context.
+ioctl
@jdstrand

jdstrand Feb 9, 2017

Contributor

This seems like the wrong approach. We will never be able to adjust seccomp policy that requires changes to snap-confine if we wait for 'snap-confine can read this syntax' since a package might be stuck for a long time. What is wrong with the exec'ing snap-confine from core approach?

@zyga

zyga Feb 9, 2017

Contributor

We've discussed this on a hangout so I'll just reply with a quick summary:

  • this is a temporary fix to unbreak the world
  • we will use snap-confine from the core
  • the patch a09abe7 should be reverted as a part of that work
@jdstrand

jdstrand Feb 9, 2017

Contributor

Similar as with quota, can you do this:

# TIOCSTI allows for faking input (man tty_ioctl)
# TODO: this should be scaled back even more
#ioctl - !TIOCSTI
# FIXME: replace this with the filter of TIOCSTI once snap-confine can read this syntax
# See LP:#1662489 for context.
ioctl
@zyga

zyga Feb 9, 2017

Contributor

Done

+ continue
+ }
+ // Refresh security of this snap and backend
+ if err := backend.Setup(snapInfo, opts, m.repo); err != nil {
@jdstrand

jdstrand Feb 9, 2017

Contributor

How atomic is this operation? Since this happens outside of install/refresh/revert it seems possible for a snap to try to start while this is happening. Is there a race here?

@zyga

zyga Feb 9, 2017

Contributor

It runs before anything else can run, during setup of the snapd process.

@jdstrand

jdstrand Feb 9, 2017

Contributor

Ok, but OnClassic, imagine a core refresh comes in at the same time that the user is trying to execute the command who's profile is being refreshed. What will happen?

@zyga

zyga Feb 9, 2017

Contributor

We use atomic rewrite of sorts (move) so we should only see one state.

interfaces: use seccomp profile syntax readable by stable snap-confine
This patch reverts useful security hardening patches done by jdstrand in
order to unbreak people tracking the edge channel on core. Because
snap-confine is not re-executed yet we don't have a way to introduce new
seccomp syntax in a compatible way.

For the time being (before we allow snap-confine to run from core snap
directly) we need this to generate profiles that actually work.

This patch is designed to be reverted easily. It does not undo changes
to snap-confine that were made along the way as they are not the
problem.

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

+1 on policy changes and approach.

@zyga zyga merged commit cdf16fc into snapcore:master Feb 9, 2017

3 of 6 checks passed

xenial-i386 autopkgtest finished (failure)
Details
xenial-ppc64el autopkgtest finished (failure)
Details
zesty-amd64 autopkgtest finished (failure)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
xenial-amd64 autopkgtest finished (success)
Details
yakkety-amd64 autopkgtest finished (success)
Details

@zyga zyga deleted the zyga:freshen-derivative-content-on-startup branch Feb 9, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment