Bug 1409895 - Deny getcwd in the Linux content process sandbox. r?gcp draft
authorJed Davis <jld@mozilla.com>
Mon, 20 Nov 2017 10:47:54 -0700
changeset 709472 7b5989fb3cbbbe51426e7df798a57201383753e2
parent 709470 45a162ba1768323fa2cb4053b380d7ea96cb607f
child 743431 7b56f57edd994c9d5adb2f90b46195e27bb791be
push id92659
push userbmo:jld@mozilla.com
push dateFri, 08 Dec 2017 04:55:20 +0000
reviewersgcp
bugs1409895
milestone59.0a1
Bug 1409895 - Deny getcwd in the Linux content process sandbox. r?gcp getcwd won't do anything useful once we start chroot()ing to remove filesystem access; with this patch it will at least fail the same way regardless of whether user namespaces are available or if other factors prevent complete FS isolation. Bonus fix: improve the comments for this group of syscalls. MozReview-Commit-ID: KueZzly2mlO
security/sandbox/linux/SandboxFilter.cpp
--- a/security/sandbox/linux/SandboxFilter.cpp
+++ b/security/sandbox/linux/SandboxFilter.cpp
@@ -727,23 +727,25 @@ public:
     switch (sysno) {
 #ifdef DESKTOP
     case __NR_getppid:
       return Trap(GetPPidTrap, nullptr);
 
     CASES_FOR_statfs:
       return Trap(StatFsTrap, nullptr);
 
-      // Filesystem syscalls that need more work to determine who's
-      // using them, if they need to be, and what we intend to about it.
+      // GTK's theme parsing tries to getcwd() while sandboxed, but
+      // only during Talos runs.
     case __NR_getcwd:
-    CASES_FOR_fstatfs:
-    CASES_FOR_fchown:
-    case __NR_fchmod:
-    case __NR_flock:
+      return Error(ENOENT);
+
+    CASES_FOR_fstatfs: // fontconfig, pulseaudio, GIO (see also statfs)
+    CASES_FOR_fchown: // pulseaudio
+    case __NR_fchmod: // pulseaudio
+    case __NR_flock: // graphics
       return Allow();
 
       // Bug 1354731: proprietary GL drivers try to mknod() their devices
     case __NR_mknod: {
       Arg<mode_t> mode(1);
       return If((mode & S_IFMT) == S_IFCHR, Error(EPERM))
         .Else(InvalidSyscall());
     }