summaryrefslogtreecommitdiff
path: root/D146271.diff
blob: fd2e0b0871c97d58151f1b7d77e5f886cbf6cdf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
diff -up firefox-101.0/security/sandbox/linux/SandboxFilter.cpp.D146271.diff firefox-101.0/security/sandbox/linux/SandboxFilter.cpp
--- firefox-101.0/security/sandbox/linux/SandboxFilter.cpp.D146271.diff	2022-05-27 01:16:59.000000000 +0200
+++ firefox-101.0/security/sandbox/linux/SandboxFilter.cpp	2022-06-09 09:59:35.569235176 +0200
@@ -125,28 +125,12 @@ namespace mozilla {
 // denied if no broker client is provided by the concrete class.
 class SandboxPolicyCommon : public SandboxPolicyBase {
  protected:
-  enum class ShmemUsage : uint8_t {
-    MAY_CREATE,
-    ONLY_USE,
-  };
-
-  enum class AllowUnsafeSocketPair : uint8_t {
-    NO,
-    YES,
-  };
-
+  // Subclasses can assign these in their constructors to loosen the
+  // default settings.
   SandboxBrokerClient* mBroker = nullptr;
   bool mMayCreateShmem = false;
   bool mAllowUnsafeSocketPair = false;
 
-  explicit SandboxPolicyCommon(SandboxBrokerClient* aBroker,
-                               ShmemUsage aShmemUsage,
-                               AllowUnsafeSocketPair aAllowUnsafeSocketPair)
-      : mBroker(aBroker),
-        mMayCreateShmem(aShmemUsage == ShmemUsage::MAY_CREATE),
-        mAllowUnsafeSocketPair(aAllowUnsafeSocketPair ==
-                               AllowUnsafeSocketPair::YES) {}
-
   SandboxPolicyCommon() = default;
 
   typedef const sandbox::arch_seccomp_data& ArgsRef;
@@ -1228,11 +1212,13 @@ class ContentSandboxPolicy : public Sand
  public:
   ContentSandboxPolicy(SandboxBrokerClient* aBroker,
                        ContentProcessSandboxParams&& aParams)
-      : SandboxPolicyCommon(aBroker, ShmemUsage::MAY_CREATE,
-                            AllowUnsafeSocketPair::YES),
-        mParams(std::move(aParams)),
+      : mParams(std::move(aParams)),
         mAllowSysV(PR_GetEnv("MOZ_SANDBOX_ALLOW_SYSV") != nullptr),
-        mUsingRenderDoc(PR_GetEnv("RENDERDOC_CAPTUREOPTS") != nullptr) {}
+        mUsingRenderDoc(PR_GetEnv("RENDERDOC_CAPTUREOPTS") != nullptr) {
+    mBroker = aBroker;
+    mMayCreateShmem = true;
+    mAllowUnsafeSocketPair = true;
+  }
 
   ~ContentSandboxPolicy() override = default;
 
@@ -1762,9 +1748,10 @@ UniquePtr<sandbox::bpf_dsl::Policy> GetM
 // segments, so it may need file brokering.
 class RDDSandboxPolicy final : public SandboxPolicyCommon {
  public:
-  explicit RDDSandboxPolicy(SandboxBrokerClient* aBroker)
-      : SandboxPolicyCommon(aBroker, ShmemUsage::MAY_CREATE,
-                            AllowUnsafeSocketPair::NO) {}
+  explicit RDDSandboxPolicy(SandboxBrokerClient* aBroker) {
+    mBroker = aBroker;
+    mMayCreateShmem = true;
+  }
 
 #ifndef ANDROID
   Maybe<ResultExpr> EvaluateIpcCall(int aCall, int aArgShift) const override {
@@ -1875,9 +1862,10 @@ UniquePtr<sandbox::bpf_dsl::Policy> GetD
 // the SocketProcess sandbox looks like.
 class SocketProcessSandboxPolicy final : public SandboxPolicyCommon {
  public:
-  explicit SocketProcessSandboxPolicy(SandboxBrokerClient* aBroker)
-      : SandboxPolicyCommon(aBroker, ShmemUsage::MAY_CREATE,
-                            AllowUnsafeSocketPair::NO) {}
+  explicit SocketProcessSandboxPolicy(SandboxBrokerClient* aBroker) {
+    mBroker = aBroker;
+    mMayCreateShmem = true;
+  }
 
   static intptr_t FcntlTrap(const sandbox::arch_seccomp_data& aArgs,
                             void* aux) {
@@ -2013,9 +2001,10 @@ UniquePtr<sandbox::bpf_dsl::Policy> GetS
 
 class UtilitySandboxPolicy : public SandboxPolicyCommon {
  public:
-  explicit UtilitySandboxPolicy(SandboxBrokerClient* aBroker)
-      : SandboxPolicyCommon(aBroker, ShmemUsage::MAY_CREATE,
-                            AllowUnsafeSocketPair::NO) {}
+  explicit UtilitySandboxPolicy(SandboxBrokerClient* aBroker) {
+    mBroker = aBroker;
+    mMayCreateShmem = true;
+  }
 
   ResultExpr PrctlPolicy() const override {
     Arg<int> op(0);
bgstack15