Bug 1434528 - Adjust sandbox feature detection to deal with Ubuntu guest accounts. r?gcp draft
authorJed Davis <jld@mozilla.com>
Thu, 08 Feb 2018 17:46:42 -0700
changeset 752891 eeef45a0a2cc8efcd432351f1a5726a4374118f1
parent 752350 8cc2427a322caa1e2c09ca3957335f88e573dc7a
push id98416
push userbmo:jld@mozilla.com
push dateFri, 09 Feb 2018 06:27:47 +0000
reviewersgcp
bugs1434528
milestone60.0a1
Bug 1434528 - Adjust sandbox feature detection to deal with Ubuntu guest accounts. r?gcp Guest sessions on Ubuntu (and maybe other distributions that use LightDM?) apply an AppArmor policy that allows CLONE_NEWUSER but doesn't allow using any of the capabilities it grants, or even configuring the new user namespace. This patch causes those environments to be detected as not supporting unprivileged user namespaces, because for all practical purposes they don't. MozReview-Commit-ID: HVkoBakRwaA
security/sandbox/linux/SandboxInfo.cpp
--- a/security/sandbox/linux/SandboxInfo.cpp
+++ b/security/sandbox/linux/SandboxInfo.cpp
@@ -132,17 +132,21 @@ CanCreateUserNamespace()
   // This is run at static initializer time, while single-threaded, so
   // locking isn't needed to access the environment.
   static const char kCacheEnvName[] = "MOZ_ASSUME_USER_NS";
   const char* cached = getenv(kCacheEnvName);
   if (cached) {
     return cached[0] > '0';
   }
 
-  pid_t pid = syscall(__NR_clone, SIGCHLD | CLONE_NEWUSER,
+  // Bug 1434528: In addition to CLONE_NEWUSER, do something that uses
+  // the new capabilities (in this case, cloning another namespace) to
+  // detect AppArmor policies that allow CLONE_NEWUSER but don't allow
+  // doing anything useful with it.
+  pid_t pid = syscall(__NR_clone, SIGCHLD | CLONE_NEWUSER | CLONE_NEWPID,
                       nullptr, nullptr, nullptr, nullptr);
   if (pid == 0) {
     // In the child.  Do as little as possible.
     _exit(0);
   }
   if (pid == -1) {
     // Failure.
     MOZ_ASSERT(errno == EINVAL || // unsupported