|
|
Log in / Subscribe / Register

A container-confinement breakout

A container-confinement breakout

Posted Mar 6, 2019 19:14 UTC (Wed) by cyphar (subscriber, #110703)
Parent article: A container-confinement breakout

There has been an update on this from the runc side of things. Quite a few folks have complained about the new memory overhead in memfd_create(2) -- since it's done after cgroup attachment it gets accounted as container usage (since we are a Go binary this ends up being 10MB which is fairly significant). There is also the issue of kernel support -- aside from old kernels we also found out that RHEL's kernel appears to have issues with their memfd_create(2) backport.

All of this has resulted in a PR I've posted[1] which solves the problem using a temporary (MNT_DETACH) read-only bind-mount of /proc/self/exe in an attempt to avoid the memory overhead -- and in principle because we create the read-only bind-mount ourselves and detached it's very unlikely a host process will accidentally make it read-write during the "runc init" window. If that fails, we then try memfd_create(2) followed by O_TMPFILE (or failing that, mksotemp(3)) inside the runc state directory -- which we need to have read-write access to in normal operation.

I've also re-sent v5 of the AT_THIS_ROOT patchset (which includes the ability to scope #! resolution) to the ML today.

[1]: https://github.com/opencontainers/runc/pull/1984


to post comments

A container-confinement breakout

Posted Mar 6, 2019 19:25 UTC (Wed) by cyphar (subscriber, #110703) [Link]

> and in principle because we create the read-only bind-mount ourselves and detached it's very unlikely a host process will accidentally make it read-write during the "runc init" window.

Scratch this, I just remembered as I was writing this comment that you could just remount it as read-write (not sure why I didn't consider that before). In that case, I will go with the overlayfs solution (where we create an overlayfs and open the upper-layer version of the binary). It will be quite ugly because you can't overlayfs on top of /proc/self -- and bind-mounts won't help either because overlayfs doesn't see them.

I have had a looming feeling for the past month or so it would've just been easier to go the LXC route and tell everyone that running containers as root is a really bad idea, and that they should expect reasonable security from such a configuration.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds