tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

SandboxReporterCommon.h (2004B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
      5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef mozilla_SandboxReporterCommon_h
      8 #define mozilla_SandboxReporterCommon_h
      9 
     10 #include "mozilla/IntegerTypeTraits.h"
     11 
     12 #include <sys/types.h>
     13 
     14 // Note: this is also used in libmozsandbox, so dependencies on
     15 // symbols from libxul probably won't work.
     16 
     17 namespace mozilla {
     18 static const size_t kSandboxSyscallArguments = 6;
     19 
     20 // This struct represents a system call that was rejected by a
     21 // seccomp-bpf policy.
     22 struct SandboxReport {
     23  // In the future this may include finer distinctions than
     24  // GeckoProcessType -- e.g., whether a content process can load
     25  // file:/// URLs, or if it's reserved for content with certain
     26  // user-granted permissions.
     27  enum class ProcType : uint8_t {
     28    CONTENT,
     29    FILE,
     30    MEDIA_PLUGIN,
     31    RDD,
     32    SOCKET_PROCESS,
     33    UTILITY,
     34  };
     35 
     36  // The syscall number and arguments are usually `unsigned long`, but
     37  // that causes ambiguous overload errors with nsACString::AppendInt.
     38  using ULong = UnsignedStdintTypeForSize<sizeof(unsigned long)>::Type;
     39 
     40  // This time uses CLOCK_MONOTONIC_COARSE.  Displaying or reporting
     41  // it should usually be done relative to the current value of that
     42  // clock (or the time at some other event of interest, like a
     43  // subsequent crash).
     44  struct timespec mTime;
     45 
     46  // The pid/tid values, like every other field in this struct, aren't
     47  // authenticated and a compromised process could send anything, so
     48  // use the values with caution.
     49  pid_t mPid;
     50  pid_t mTid;
     51  ProcType mProcType;
     52  ULong mSyscall;
     53  ULong mArgs[kSandboxSyscallArguments];
     54 
     55  SandboxReport() : mPid(0) {}
     56  bool IsValid() const { return mPid > 0; }
     57 };
     58 
     59 }  // namespace mozilla
     60 
     61 #endif  // mozilla_SandboxReporterCommon_h