Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

Add spread tests for mount namespace layout #169

Merged
merged 5 commits into from Oct 13, 2016
Merged

Add spread tests for mount namespace layout #169

merged 5 commits into from Oct 13, 2016

Conversation

zyga
Copy link
Contributor

@zyga 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

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>
Copy link
Contributor

@tyhicks tyhicks left a comment

Choose a reason for hiding this comment

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

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.

import json
import re

_boring_fs = set(['cgroup', 'fusectl', 'debugfs', 'pstore', 'securityfs', 'mqueue', 'hugetlbfs'])
Copy link
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

"fs_type": "ext4",
"mount_opts": "rw,noatime",
"mount_point": "/etc",
"mount_src": "/dev/sda",
Copy link
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

So, the remapping script needed some love.

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

zyga commented Oct 11, 2016

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

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>
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
@zyga
Copy link
Contributor Author

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
@zyga zyga deleted the mount-ns-layout branch October 13, 2016 07:00
@zyga zyga restored the mount-ns-layout branch October 13, 2016 19:16
@zyga zyga deleted the mount-ns-layout branch October 13, 2016 19:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants