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

abi <abi/4.0>,

include <tunables/global>

@{exec_path} = @{bin}/nvidia-smi
profile nvidia-smi @{exec_path} {
  include <abstractions/base>
  include <abstractions/consoles>
  include <abstractions/nvidia-strict>

  @{exec_path} mr,

  @{sys}/devices/system/node/ r,
  @{sys}/devices/system/node/node@{int}/cpumap r,

        @{PROC}/devices r,
        @{PROC}/driver/nvidia/capabilities/mig/config r,
        @{PROC}/driver/nvidia/capabilities/mig/monitor r,
  owner @{PROC}/@{pid}/cmdline r,

  /dev/char/@{dynamic}:@{int} w,          # For dynamic assignment range 234 to 254, 384 to 511
  /dev/nvidia-caps/ rw,
  /dev/nvidia-caps/nvidia-cap@{int} r,
  /dev/nvidia-uvm rw,
  /dev/nvidia-uvm-tools r,

  include if exists <local/nvidia-smi>
}

# vim:syntax=apparmor
