libbrillo: Fix the mount namespace creation

MountNamespace::Create() creates the mount namespace by first unsharing
a new mount namespace and then bind mounting the /proc/self/ns/mnt file
of that namespace to the provided path. However, mount namespaces do
not allow bind mounting /proc/[pid]/ns/mnt file if the process is in the
same mount namespace.

This CL fixes this bug in the existing code by moving the mount
operation to the parent process from the child process where a new
namespace is unshared.

BUG=chromium:1052197
TEST=FEATURES=test emerge-betty libbrillo
TEST=USE="user_session_isolation" emerge-betty libbrillo chromeos-login
TEST=cros deploy --board=betty localhost:9222 libbrillo chromeos-login
system boots and login success
PID=pgrep -o -f /opt/google/chrome
readlink /proc/${PID}/ns/mnt and readlink /proc/1/ns/mnt are different

Change-Id: I3856f9c8d160feb6fdff32e9abdbbfda0947d3f5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/2147356
Tested-by: Betul Soysal <betuls@google.com>
Commit-Queue: Betul Soysal <betuls@google.com>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Jorge Lucangeli Obes <jorgelo@chromium.org>
Auto-Submit: Betul Soysal <betuls@google.com>
Cr-Mirrored-From: https://chromium.googlesource.com/chromiumos/platform2
Cr-Mirrored-Commit: 2ba7a03d1bf739e3884a22ed300aa2c8a1aadc25
5 files changed
tree: 95efb90f0ea00d4d0a75fbb2d9470faec8cf8ce6
  1. brillo/
  2. install_attributes/
  3. policy/
  4. BUILD.gn
  5. libpolicy.ver
  6. OWNERS
  7. PRESUBMIT.cfg
  8. README.md
  9. testrunner.cc
README.md

libbrillo: platform utility library

libbrillo is a shared library meant to hold common utility code that we deem useful for platform projects. It supplements the functionality provided by libbase/libchrome since that project, by design, only holds functionality that Chromium (the browser) needs. As a result, this tends to be more OS-centric code.

AOSP Usage

This project is also used by Update Engine which is maintained in AOSP. However, AOSP doesn't use this codebase directly, it maintains its own libbrillo fork.

To help keep the projects in sync, we have a gsubtree set up on our GoB: https://chromium.googlesource.com/chromiumos/platform2/libbrillo/

This allows AOSP to cherry pick or merge changes directly back into their fork.