public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Martin Vaeth <martin@mvath.de>
To: gentoo-dev@lists.gentoo.org
Subject: [gentoo-dev] Re: An example overlayfs sandbox test
Date: Sun, 24 Sep 2017 18:11:44 +0000 (UTC)	[thread overview]
Message-ID: <slrnosftb8.mgi.martin@lounge.imp.fu-berlin.de> (raw)
In-Reply-To: CAGfcS_mDgWfAeM6Ga45okM+noPf3wT6PojHv-qTa5VuU4W3Emw@mail.gmail.com

Rich Freeman <rich0@gentoo.org> wrote:
> On Sun, Sep 24, 2017 at 4:24 AM, Martin Vaeth <martin@mvath.de> wrote:
>> Tim Harder <radhermit@gentoo.org> wrote:
>>
>> It is the big advantage of overlay that it is implemented in
>> kernel and does not involve any time-consuming checks during
>> normal file operations.
>
> Why would you expect containers to behave any differently?

For overlay, there is only one directory to be checked in
addition for every file access.

For containers, at least a dozens of binds are minimally required
(/usr /proc /sys /dev ...). But as you mentioned in your posting,
if you want to take more care you easily have thousands of bind mounts.
At least implicitly in the kernel, all of these binds must be checked
for every file access. I am not sure whether this happens very quickly
by hashing (so that essentially really only the creation costs time).

As mentioned, I do not have actual timing results. I am just afraid
that it might easily cost more than a context-switch which already
gives a slowdown for fuse-overlay which is so large that I would
not recommend it for a sandbox.

> Now, I am concerned about the time to create the container, if we're
> going to specify individual files, but the same would be true of an
> overlay. [...]
> to populate an overlayfs with just that specific list of files.

No. For overlay you need only one mount (not even a bind)
and only one directory traversal at the end to check for
violations.
The nice thing is that this is practically independent of
the number or structure of directories/files you want to protect,
i.e. it scales perfectly well.
For the more fine-grained approach, you just delete the files
you do not want to have in the beginning. Not sure, how quick this
can be done, but once it is done, the slowdown when running the
sandbox is independent of the number of deleted files (because
here certainly only one hash lookup is required).

Of course, as mgorny already observed, overlay alone is not an
absolute protection (e.g. against writing to some /dev/...),
so perhaps it is a good idea to use containers as an additional
protection level.

> If you just replicate the current sandbox
> functionality then setup time is tiny

I am not so much concerned about the setup time but more about the
delay caused for file operations once the sandbox is set up.
Perhaps even a dozen bind directories already give a considerable
slowdown...



  reply	other threads:[~2017-09-24 18:12 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-22 23:43 [gentoo-dev] An example overlayfs sandbox test James McMechan
2017-09-23  0:18 ` Rich Freeman
2017-09-23  1:29   ` James McMechan
2017-09-23  2:26     ` Rich Freeman
2017-09-24  4:36       ` Tim Harder
2017-09-24 15:39       ` James McMechan
2017-09-23 23:42 ` Alec Warner
2017-09-23 23:59   ` Rich Freeman
2017-09-24  4:44     ` Tim Harder
2017-09-24  8:24       ` [gentoo-dev] " Martin Vaeth
2017-09-24 11:31         ` Rich Freeman
2017-09-24 18:11           ` Martin Vaeth [this message]
2017-09-25  0:49             ` Rich Freeman
2017-09-25 15:27               ` Martin Vaeth
2017-09-25 15:34                 ` Rich Freeman
2017-09-27 16:51                   ` Martin Vaeth
2017-09-24 12:55 ` [gentoo-dev] " Michał Górny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=slrnosftb8.mgi.martin@lounge.imp.fu-berlin.de \
    --to=martin@mvath.de \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox