Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 316273 - app-emulation/lxc-0.7.0: read-only bind mounts don't work
Summary: app-emulation/lxc-0.7.0: read-only bind mounts don't work
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High major (vote)
Assignee: Diego Elio Pettenò (RETIRED)
URL: http://sourceforge.net/mailarchive/fo...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-20 03:15 UTC by Boney McCracker
Modified: 2010-06-22 15:18 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
proposed lxc-0.6.5-bind-remount.patch (lxc-0.6.5-bind-remount.patch,1.02 KB, patch)
2010-04-20 03:22 UTC, Boney McCracker
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Boney McCracker 2010-04-20 03:15:01 UTC
lxc fails to make read-only bind mounts as documented.
Read-only bind mounts are important to many use cases.

A simple patch has been submitted upstream, but it's not yet clear to me what will done with it.  I have tested the patch and it works.  Here it is, for your consideration (implement now vs. wait for upstream fix).


Although lxc is only in portage for experimentation, it may be worth considering this patch.  This is a major loss of functionality that effects the security of a security-oriented application.  

Reproducible: Always

Steps to Reproduce:
In short, a line like this in a container's configuration file should have the effect of bind-mounting the file (e.g. /sbin directory below) within the container and making it read-only:

lxc.mount.entry = /sbin /lxc/container07/sbin none ro,bind 0 0

Or in a fstab-formatted file referred to by a "lxc.mount" entry in the config file, it would simply be:

 /sbin /lxc/container07/sbin none ro,bind 0 0

IBM's documentation and templates are full of these "ro,bind" mount entries.
Actual Results:  
Unfortunately, it doesn't work.  It bind-mounts, but gives a little warning that it "appears to mounted read-write". :(

Sad face, considering the whole point of this is secure compartmentalization.

Expected Results:  
Obviously, it ought to bind-mount it and place it in read-only mode.



It isn't exactly surprising that this doesn't work, since 'mount' doesn't support combining options such as "ro" with "bind" (one must remount read-only).

Normally, a read-only bind mount requires two steps:

 mount -o bind /sbin /lxc/container07/sbin
 mount -o remount,ro /lxc/container07/sbin

One may work around this by executing a script (after starting the container) to remount the appropriate things in read-only mode.  However, the simple patch mentioned above (and attached) does seem to fix this.

Refer to the URL for the discussion presenting the patch.
Comment 1 Boney McCracker 2010-04-20 03:22:01 UTC
Created attachment 228469 [details, diff]
proposed lxc-0.6.5-bind-remount.patch

This is the patch, Created by Ciprian Dorin. 

I regenerated a clean patch by editing the code according to the changes documented in the diff at the URL referenced above.

For me, it makes lxc worth using.  You gentlemen can decide whether to include it in the ebuild.
Comment 2 Wormo (RETIRED) gentoo-dev 2010-04-20 06:05:00 UTC
Thank you, this does sound like an important fix. Assigning to maintainers.
Comment 3 Walter 2010-06-01 21:00:09 UTC
I would also love to see this fix integrated.

Thanks a lot for taking the time to submit this John.

(From a fellow early gentoo lxc adopter.)
Comment 4 Boney McCracker 2010-06-22 04:58:52 UTC
The bug still exists in lxc-0.7.0.

The patch still works on 0.7.0.
Comment 5 Boney McCracker 2010-06-22 15:18:13 UTC
I have communicated with the developers.  This was inadvertently left out of this release and will be included in an 0.7.1 release.

http://sourceforge.net/mailarchive/message.php?msg_name=4C20B169.1010004%40free.fr

Resolve to "Upstream".