Skip to content

Conversation

@crosbymichael
Copy link
Contributor

Closes #5445
Fixes #5444

This is a rebase and updates ontop of #5445

ping @jpetazzo

@creack
Copy link
Contributor

creack commented May 1, 2014

I can't build the docker image with this PR. got error:
2014/05/01 20:01:58 read-only file system

@crosbymichael
Copy link
Contributor Author

@creack fixed

@crosbymichael
Copy link
Contributor Author

ping @unclejack @vieux

@creack
Copy link
Contributor

creack commented May 1, 2014

@crosbymichael same error but on step 8 this time.

@crosbymichael
Copy link
Contributor Author

@creack it's an apparmor issue, we are fixing it in #5534

jpetazzo and others added 5 commits May 1, 2014 15:26
It has been pointed out that some files in /proc and /sys can be used
to break out of containers. However, if those filesystems are mounted
read-only, most of the known exploits are mitigated, since they rely
on writing some file in those filesystems.

This does not replace security modules (like SELinux or AppArmor), it
is just another layer of security. Likewise, it doesn't mean that the
other mitigations (shadowing parts of /proc or /sys with bind mounts)
are useless. Those measures are still useful. As such, the shadowing
of /proc/kcore is still enabled with both LXC and native drivers.

Special care has to be taken with /proc/1/attr, which still needs to
be mounted read-write in order to enable the AppArmor profile. It is
bind-mounted from a private read-write mount of procfs.

All that enforcement is done in dockerinit. The code doing the real
work is in libcontainer. The init function for the LXC driver calls
the function from libcontainer to avoid code duplication.

Docker-DCO-1.1-Signed-off-by: Jérôme Petazzoni <[email protected]> (github: jpetazzo)
Docker-DCO-1.1-Signed-off-by: Michael Crosby <[email protected]> (github: crosbymichael)
This also cleans up some of the left over restriction paths code from
before.
Docker-DCO-1.1-Signed-off-by: Michael Crosby <[email protected]> (github: crosbymichael)
Docker-DCO-1.1-Signed-off-by: Michael Crosby <[email protected]> (github: crosbymichael)
Docker-DCO-1.1-Signed-off-by: Michael Crosby <[email protected]> (github: crosbymichael)
@vieux
Copy link
Contributor

vieux commented May 1, 2014

LGTM

@crosbymichael
Copy link
Contributor Author

@creack another cache bust but it will work this time ;)

There is not need for the remount hack, we use aa_change_onexec so the
apparmor profile is not applied until we exec the users app.
Docker-DCO-1.1-Signed-off-by: Michael Crosby <[email protected]> (github: crosbymichael)
@crosbymichael
Copy link
Contributor Author

@creack @unclejack I believe the last commit will fix the issues that you were seeing

@unclejack
Copy link
Contributor

LGTM

1 similar comment
@creack
Copy link
Contributor

creack commented May 2, 2014

LGTM

creack added a commit that referenced this pull request May 2, 2014
Mount /proc and /sys read-only, except in privileged containers
@creack creack merged commit 1c5a312 into moby:master May 2, 2014
@creack creack deleted the restrict-proc branch May 2, 2014 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/proc/sys/kernel/hostname doesn't exist inside container

5 participants