# AM·OS IMA policy.
#
# Appraise only executable content. Every ELF binary executed via
# BPRM_CHECK, and every shared library or PIE binary mapped for
# execution via MMAP_CHECK, must carry a valid IMA signature from the
# AM·OS IMA key. Nothing else is appraised. Data files, configuration,
# logs, and databases are intentionally out of scope; protecting them
# requires permissions and MAC, not IMA.
#
# Pseudo-filesystems are excluded from both measurement and appraisal.
# They are kernel-generated, do not support extended attributes, and
# carry no executable content.

dont_measure  fsmagic=0x9fa0        # proc
dont_measure  fsmagic=0x62656572    # sysfs
dont_measure  fsmagic=0x64626720    # debugfs
dont_measure  fsmagic=0x01021994    # tmpfs
dont_measure  fsmagic=0x73636673    # securityfs
dont_measure  fsmagic=0x1cd1        # devpts
dont_measure  fsmagic=0x63677270    # cgroup2

dont_appraise fsmagic=0x9fa0
dont_appraise fsmagic=0x62656572
dont_appraise fsmagic=0x64626720
dont_appraise fsmagic=0x01021994   # tmpfs
dont_appraise fsmagic=0x73636673
dont_appraise fsmagic=0x1cd1
dont_appraise fsmagic=0x63677270
dont_appraise fsmagic=0x858458f6    # ramfs (initramfs)
# dont_appraise fowner=www-data

# Measurement: audit trail of executed code.
measure func=BPRM_CHECK mask=MAY_EXEC
measure func=MMAP_CHECK mask=MAY_EXEC

# Appraisal: enforce signatures on executed code.
appraise func=BPRM_CHECK mask=MAY_EXEC appraise_type=imasig
appraise func=MMAP_CHECK mask=MAY_EXEC appraise_type=imasig


# round 2 (when the above works, test with addtions/edits)
# Kernel modules (finit_module path)
# appraise func=MODULE_CHECK appraise_type=imasig
# measure  func=MODULE_CHECK

# Firmware blobs
# appraise func=FIRMWARE_CHECK appraise_type=imasig
# measure  func=FIRMWARE_CHECK

# The IMA policy itself (so it cannot be replaced at runtime with an unsigned policy)
# appraise func=POLICY_CHECK appraise_type=imasig
# measure  func=POLICY_CHECK

# Optional but recommended if you support kexec
# appraise func=KEXEC_KERNEL_CHECK appraise_type=imasig
# measure  func=KEXEC_KERNEL_CHECK
# appraise func=KEXEC_INITRAMFS_CHECK appraise_type=imasig   # if you want this too

# appraise func=MMAP_CHECK_REQPROT mask=MAY_EXEC appraise_type=imasig
# measure  func=MMAP_CHECK_REQPROT mask=MAY_EXEC

# They strengthen the running system after the initramfs has handed off to the real root:Prevent loading of unsigned kernel modules or firmware.
# Prevent replacing the IMA policy at runtime with an unsigned one.
# Prevent kexec of an unsigned kernel/initramfs (if you add those rules).

# The initramfs remains outside the protection of these rules when Secure Boot is not present.

