Add spread tests for mount namespace layout #169

Merged
merged 5 commits into from Oct 13, 2016

Conversation

Projects
None yet
2 participants
Collaborator

zyga commented Oct 11, 2016

This patch adds a simple test that looks at /proc/self/mountinfo within
confined applications. The test discards some information that is too
variable to be useful but retains the most essential facts.

This test will be changed by the upcoming /media sharing patches. It is
intended to be useful for before/after comparison.

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

Add spread tests for mount namespace layout
This patch adds a simple test that looks at /proc/self/mountinfo within
confined applications. The test discards some information that is too
variable to be useful but retains the most essential facts.

This test will be changed by the upcoming /media sharing patches. It is
intended to be useful for before/after comparison.

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

This looks like a really nice test. I didn't spend too much time looking at the mountinfo contents and focused mostly on what the test was verifying at a higher level. I only had two comments/questions that I'd like cleared up before giving my ack.

+ "fs_type": "ext4",
+ "mount_opts": "rw,noatime",
+ "mount_point": "/etc",
+ "mount_src": "/dev/sda",
@tyhicks

tyhicks Oct 11, 2016

Collaborator

Isn't the /dev/sda portion going to be brittle? For example, if testing in QEMU using a virtio, I suspect this will be /dev/vda.

@zyga

zyga Oct 11, 2016

Collaborator

Nice catch, I'll change it to /dev/BLOCK or something like this

+import json
+import re
+
+_boring_fs = set(['cgroup', 'fusectl', 'debugfs', 'pstore', 'securityfs', 'mqueue', 'hugetlbfs'])
@tyhicks

tyhicks Oct 11, 2016

Collaborator

Why are we ignoring these filesystems?

At least cgroup, debugfs, and securityfs are very security sensitive. At least a comment on the definition of a boring filesystem would be helpful.

@zyga

zyga Oct 11, 2016

Collaborator

Ha, because I wanted to make it shorter (because there was an instability that I joust found and fixed). I'll amend this test to ignore nothing.

Fix the remapping script
So, the remapping script needed some love.

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

zyga commented Oct 11, 2016

I fixed both comments and more (the processing script was lousy so I wrote a real one)

zyga added some commits Oct 11, 2016

Split sorting of mountinfo entries
Various parts of the system can come up with nondeterministic ordering.
This results in, e.g. cgroups being ordered randomly from one boot to
another.

The goal of the script is to discard the randomness so it resorted to
sorting but the sort criteria contains random names from various bits of
snap-confine setup.

This patch splits the sorting so that we first discard randomness from
mount_point alone (giving us something that we can sort) and then sorts
the list by a few more factors, after which the remainder of the
de-randomization is performed.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Differentiate between core and ubuntu-core layout
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Make sorting more robust, sort only after derandomization
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Collaborator

zyga commented Oct 13, 2016

FYI: I finally fixed the non-determinism. It appears that there are differences between the core and ubuntu-core snaps. This is now reflected in the test.

@zyga zyga merged commit e78e497 into master Oct 13, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@zyga zyga deleted the mount-ns-layout branch Oct 13, 2016

@zyga zyga restored the mount-ns-layout branch Oct 13, 2016

@zyga zyga deleted the mount-ns-layout branch Oct 13, 2016

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