minijail: use new_root as put_old in pivot_root(2)

Instead of create a temp directory '.minijail_pivot' for put_old, reuse
the new_root as put_old. By doing this, we can use pivot_root even if we
don't have write permissions in that directory. Since the old root is
mounted over the new root, keep fds of both old and new root so that we
can use 'fchdir' to move between them.
The idea comes from lxc.
https://github.com/lxc/lxc/commit/2d489f9e87fa0cccd8a1762680a43eeff2fe1b6e

BUG=chromium:517844
TEST=security_Minijail0 passes

Change-Id: Ie446ad1d2557239c17b1a876a73459eca6d2d2ed
Reviewed-on: https://chromium-review.googlesource.com/297867
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Jorge Lucangeli Obes <jorgelo@chromium.org>
1 file changed