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

abi <abi/3.0>,

include <tunables/global>

@{exec_path} = @{bin}/irqbalance
profile irqbalance @{exec_path} flags=(attach_disconnected) {
  include <abstractions/base>

  capability net_admin,
  capability setpcap,

  network netlink raw,

  @{exec_path} mr,

  /etc/default/irqbalance r,

  / r,

  @{run}/irqbalance/irqbalance@{int}.sock w,

  @{sys}/bus/pci/devices/ r,
  @{sys}/devices/@{pci}/{class,numa_node,local_cpus,irq} r,
  @{sys}/devices/@{pci}/{vendor,device,subsystem_vendor,subsystem_device} r,
  @{sys}/devices/@{pci}/msi_irqs/ r,
  @{sys}/devices/system/cpu/cpu@{int}/ r,
  @{sys}/devices/system/cpu/cpu@{int}/cache/index@{int}/shared_cpu_map r,
  @{sys}/devices/system/cpu/cpu@{int}/topology/{,**} r,
  @{sys}/devices/system/cpu/isolated r,
  @{sys}/devices/system/node/ r,
  @{sys}/devices/system/node/node@{int}/ r,
  @{sys}/devices/system/node/node@{int}/{cpumap,meminfo} r,
  @{sys}/devices/system/cpu/nohz_full r,

  @{PROC}/interrupts r,
  @{PROC}/irq/@{int}/node r,
  @{PROC}/irq/@{int}/smp_affinity rw,

  include if exists <local/irqbalance>
}

# vim:syntax=apparmor
