Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
interfaces: implement a fuse interface #1598
Conversation
|
whitelist this please |
|
Apart from anything else, can you please patch |
|
Oh yeah, I'll do that. Must have missed it during my random grepping around to find what to change :) |
|
docs/interfaces.md done |
|
Looks good. It would be good to add a note on how this can be tested. We have a file called |
|
https://bugs.launchpad.net/bugs/1603113 is the related wishlist bug btw |
|
Yeah, so I expect the right way to test this would be to install a snap using it, so chicken and egg problem going on there :) There is no standalone tool to test fuse other than actually running a fuse filesystem, at which point you may as well make a snap out of it. Maybe @ogra1 can do that with sshfs and then a test can be added to snapd to check that the sshfs snap works. |
|
@ogra1 care to contribute a test for this interface? |
|
@fgimenez that'd be great, thanks! |
pedronis
changed the title from
Implement a fuse interface
to
interfaces: implement a fuse interface
Jul 31, 2016
|
Test proposed in stgraber/snapd#1 |
|
@fgimenez could you test the branch again now? I don't have an environment where I can easily test this right now. It looks like the spread test is hanging in travis so I can't really rely on that either. |
niemeyer
reviewed
Aug 3, 2016
| +### fuse | ||
| + | ||
| +Lets you run a fuse filesystem, accessing /dev/fuse and /sys/fs/fuse/connections. |
niemeyer
Aug 3, 2016
Contributor
This should use language that is similar to the other entries. I don't particularly like either style ("you", or "Can foo"), but consistency wins.
niemeyer
reviewed
Aug 3, 2016
| +# | ||
| + | ||
| +import os, stat, errno | ||
| +# pull in some spaghetti to make this stuff work without fuse-py being installed |
niemeyer
Aug 3, 2016
Contributor
Why do we need that? We know exactly what lives where in this context, and the guesses made in that file don't look sensible for the snap environment.
niemeyer
reviewed
Aug 3, 2016
| +import os, stat, errno | ||
| +# pull in some spaghetti to make this stuff work without fuse-py being installed | ||
| +try: | ||
| + import _find_fuse_parts |
niemeyer
Aug 3, 2016
Contributor
Let's please drop this module altogether, and do exactly what needs to be done here, if anything is necessary at all. And then, let's not ignore errors in that logic as done below.
|
The test breakages are actually about this branch itself, so need looking and addressing:
There are also conflicts. |
niemeyer
added
the
Reviewed
label
Aug 3, 2016
|
@fgimenez I did the rebase and got the unit test to pass again. Can you look at the spread result, see if it's something wrong with the interface or with the test? |
|
hey @stgraber I've proposed stgraber/snapd#3, which should resolve the current problems. It seems that somehow the previous branch changes didn't merge correctly, they are included in this PR plus more enhancements addressing the review comments. However with these changes I'm getting a
Currently the checks use the test user to try the creation of the filesystem, if they are changed to use root then I get from dmesg:
Please let me know if I can be of any help debugging this, to reproduce you can try to install the Cheers, |
|
@stgraber the fuse test is passing! \o/ the error you are getting in the upgrade test is fixed in master, merging should fix it. Thanks! :) |
|
and test is passing! |
niemeyer
reviewed
Aug 7, 2016
| + | ||
| +### fuse | ||
| + | ||
| +Lets you run a fuse filesystem, accessing /dev/fuse and /sys/fs/fuse/connections. |
|
One trivial comment still pending. @jdstrand Would appreciate a security review on this one when you have a moment. |
|
Fixed the description, rebased on master yet again and squashed some commits together to keep things clean. Hopefully travis will be happy. |
|
ping |
|
I guess this is stuck on @jdstrand right now. |
jdstrand
reviewed
Aug 8, 2016
| + | ||
| +Usage: common | ||
| +Auto-Connect: yes | ||
| + |
jdstrand
Aug 8, 2016
Contributor
Can you update this for the format in the recently committed interface documentation improvements PR?
jdstrand
reviewed
Aug 8, 2016
| @@ -60,6 +60,7 @@ var allInterfaces = []interfaces.Interface{ | ||
| NewOpticalDriveInterface(), | ||
| NewCameraInterface(), | ||
| NewBluetoothControlInterface(), | ||
| + NewFuseInterface(), | ||
| } | ||
| // Interfaces returns all of the built-in interfaces. |
jdstrand
reviewed
Aug 8, 2016
| + | ||
| +deny /etc/fuse.conf rwklx, | ||
| + | ||
| +capability sys_admin,` |
jdstrand
Aug 8, 2016
Contributor
Can you put this '`' on a line by itself so we have proper spacing between connected interfaces?
jdstrand
reviewed
Aug 8, 2016
| +/dev/fuse rw, | ||
| +/sys/fs/fuse/** rw, | ||
| + | ||
| +deny /etc/fuse.conf rwklx, |
jdstrand
Aug 8, 2016
Contributor
Because of the way interfaces work where we build up the whitelist in arbitrary ways and because deny rules override allow, we prefer to not use deny rules. Is there a reason why you have an explicit deny rule?
stgraber
Aug 8, 2016
Contributor
Not really, just shutting up a denial. Removing it will make dmesg a bit noisier but won't change anything as far as functionality.
jdstrand
reviewed
Aug 8, 2016
| @@ -249,6 +249,13 @@ Can configure network firewalling giving privileged access to networking. | ||
| * Auto-Connect: no | ||
| +### fuse | ||
| + | ||
| +Can mount fuse filesystems (as root only). |
jdstrand
Aug 8, 2016
Contributor
This says 'as root only', but down below you say 'Can run an unprivileged FUSE filesystem.'. These descriptions seem at odds.
|
@jdstrand that should be all review comments addresses. Let's see if travis is still happy. |
|
While I gave a few high-level comments, I'd like to take a close look at fuse to better understand what this interface should look like. |
|
@jdstrand any idea when you'll be doing that? I'm getting a bit tired having to rebase this almost once a day to cope with other changes that you guys are merging. Especially given that I don't actually need this interface myself anymore :) |
|
@stgraber - I started yesterday and am continuing today and likely will continue into tomorrow. It is important that we understand the security implications of the interface before we allow it and I need to perform due diligence. |
|
@stgraber Please consider the cost of rebasing compared to the cost of doing security review, code review, writing tests for it, etc. It's not like this is sitting idle on a queue. |
|
FYI, good progress has been made but the investigation continues. I can say that assuming everything checks out with the investigation, the policy will need to be fine-tuned a bit. I'll post that with my findings. |
mvo5
added
the
Blocked
label
Aug 12, 2016
|
SUMMARY: I took some time to look at this and believe that a fuse interface is ok in general and with the proper interface policy that is detailed in this response, can be manually connected at this time. This investigation was shared and discussed with the security team. After discussions with upstream and/or a deep audit we may be able to allow auto-connect of the interface. The kernel mediates the path of the actual file, not the path of the fuse mount (ie mount '/' on SNAP_DATA/mnt, then access to SNAP_DATA/mnt/etc/shadow is mediated as /etc/shadow. This is true of nested local mounts too) so there are no sandbox escapes with using this interface. Per upstream documentation, when using fusermount, mounts work as one would expect and they are mounted with fuse imposing the following restrictions:
Our fuse interface should not allow setting allow_other or allow_root so we should not allow reading /etc/fuse.conf. Unmounts and fuse aborts should not be in the main policy because our mediation is not fine-grained enough. Most fuse apps don't need to unmount their own mounts so this shouldn't be an issue. For those that do, we can introduce a 'fuse-control' interface that allows the unmounts and fuse aborts. fusermount is a userspace tool that is setuid in Ubuntu so that it has CAP_SYS_ADMIN and can perform mount operations for unprivileged users. It is not present in the core snap today and snaps can't (currently) ship setuid binaries, so unprivileged fuse mounts won't be supported at this time. If we want to support this, the core snap could ship fusermount and the security policy for the main interface could add this rule: Importantly, because fusermount is not included in the core snap and because root processes are under no obligation to use it (or libfuse), we need to enforce strict mount options (ie, nosuid and nodev) and mount paths. Furthermore, the snap-confine command creates a new mount namespace so the fuse mounts aren’t accessible to other processes outside of the app’s process, which somewhat limits the utility of the interface but it also offers some protection against misbehaving fuse filesystems since the files won’t be available in the global mount namespace or the mount namespaces of other snaps. Fuse has a long security history and the security team does not feel that the interface should be auto-connected at this time. It is believed that the interface policy detailed below covers many attacks, but a discussion with upstream and/or a detailed audit of the fuse design and kernel interface for resiliency against crafted filesystems and libfuse needs to happen before it can be considered for auto-connect. As such, the PR should:
|
stgraber
and others
added some commits
Jul 28, 2016
|
@fgimenez can you update the snap in the store to use the new interface name? |
|
@stgraber done, btw you should change https://github.com/snapcore/snapd/pull/1598/files#diff-a0b5529dbb07412519ba3f91fffda35dR33 to check for Cheers :) |
|
Travis looks happy. This should address everything @jdstrand mentioned. |
jdstrand
reviewed
Aug 16, 2016
| + | ||
| +func (s *FuseSupportInterfaceSuite) TestAutoConnect(c *C) { | ||
| + c.Check(s.iface.AutoConnect(), Equals, false) | ||
| +} |
jdstrand
Aug 16, 2016
Contributor
A TestConnectedPlug test where you search for a rule or string from each of the apparmor and seccomp policies would be a nice touch (see mpris_test.go for an example) but because you have a spread test, that is not strictly required (and I won't block on the lack of it).
|
Thank you for making these changes. +1 |
mvo5
reviewed
Aug 17, 2016
| + | ||
| +install: | ||
| + mkdir -p $(DESTDIR)/bin | ||
| + cp -a /usr/share/doc/python-fuse/examples/example/hello.py $(DESTDIR)/bin/create |
|
Looks good, thank you! |
stgraber commentedJul 28, 2016
I wrote that while working on the LXD snap. We won't actually be needing
it but figured it'd be useful to others.
Signed-off-by: Stéphane Graber stgraber@ubuntu.com