# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2021-2024 Alexandre Pujol <alexandre@pujol.io>
# SPDX-License-Identifier: GPL-2.0-only

abi <abi/3.0>,

include <tunables/global>

@{name} = brave{,-beta,-dev,-bin}
@{lib_dirs} = /opt/brave{-bin,.com}{,/@{name}}
@{config_dirs} = @{user_config_dirs}/BraveSoftware/Brave-Browser{,-Beta,-Dev}

@{exec_path} = @{lib_dirs}/chrome_crashpad_handler
profile brave-crashpad-handler @{exec_path} {
  include <abstractions/base>

  capability sys_ptrace,

  unix (send, receive) type=stream peer=(label=brave),

  ptrace peer=brave,
  signal (send) peer=brave,

  @{exec_path} mrix,

  owner "@{config_dirs}/Crash Reports/**" rwk,
  owner @{config_dirs}/CrashpadMetrics-active.pma rw,
  owner @{config_dirs}/CrashpadMetrics.pma rw,

        @{PROC}/sys/kernel/yama/ptrace_scope r,
  owner @{PROC}/@{pid}/fd/ r,
  owner @{PROC}/@{pids}/mem r,
  owner @{PROC}/@{pids}/stat r,
  owner @{PROC}/@{pids}/task/ r,

  @{sys}/devices/system/cpu/cpufreq/policy@{int}/scaling_cur_freq r,
  @{sys}/devices/system/cpu/cpufreq/policy@{int}/scaling_max_freq r,

  include if exists <local/brave-crashpad-handler>
}
