^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) What: security/ima/policy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) Date: May 2008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) Contact: Mimi Zohar <zohar@us.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) The Trusted Computing Group(TCG) runtime Integrity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) Measurement Architecture(IMA) maintains a list of hash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) values of executables and other sensitive system files
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) loaded into the run-time of this system. At runtime,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) the policy can be constrained based on LSM specific data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) Policies are loaded into the securityfs file ima/policy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) by opening the file, writing the rules one at a time and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) then closing the file. The new policy takes effect after
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) the file ima/policy is closed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) IMA appraisal, if configured, uses these file measurements
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) for local measurement appraisal.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) rule format: action [condition ...]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) action: measure | dont_measure | appraise | dont_appraise |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) audit | hash | dont_hash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) condition:= base | lsm [option]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) base: [[func=] [mask=] [fsmagic=] [fsuuid=] [uid=]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) [euid=] [fowner=] [fsname=]]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) lsm: [[subj_user=] [subj_role=] [subj_type=]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) [obj_user=] [obj_role=] [obj_type=]]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) option: [[appraise_type=]] [template=] [permit_directio]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) [appraise_flag=] [keyrings=]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) base:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) func:= [BPRM_CHECK][MMAP_CHECK][CREDS_CHECK][FILE_CHECK]MODULE_CHECK]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) [FIRMWARE_CHECK]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) [KEXEC_KERNEL_CHECK] [KEXEC_INITRAMFS_CHECK]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) [KEXEC_CMDLINE] [KEY_CHECK]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) mask:= [[^]MAY_READ] [[^]MAY_WRITE] [[^]MAY_APPEND]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) [[^]MAY_EXEC]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) fsmagic:= hex value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) fsuuid:= file system UUID (e.g 8bcbe394-4f13-4144-be8e-5aa9ea2ce2f6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) uid:= decimal value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) euid:= decimal value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) fowner:= decimal value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) lsm: are LSM specific
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) option:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) appraise_type:= [imasig] [imasig|modsig]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) appraise_flag:= [check_blacklist]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) Currently, blacklist check is only for files signed with appended
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) signature.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) keyrings:= list of keyrings
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) (eg, .builtin_trusted_keys|.ima). Only valid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) when action is "measure" and func is KEY_CHECK.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) template:= name of a defined IMA template type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) (eg, ima-ng). Only valid when action is "measure".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) pcr:= decimal value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) default policy:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) # PROC_SUPER_MAGIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) dont_measure fsmagic=0x9fa0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) dont_appraise fsmagic=0x9fa0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) # SYSFS_MAGIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) dont_measure fsmagic=0x62656572
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) dont_appraise fsmagic=0x62656572
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) # DEBUGFS_MAGIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) dont_measure fsmagic=0x64626720
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) dont_appraise fsmagic=0x64626720
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) # TMPFS_MAGIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) dont_measure fsmagic=0x01021994
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) dont_appraise fsmagic=0x01021994
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) # RAMFS_MAGIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) dont_appraise fsmagic=0x858458f6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) # DEVPTS_SUPER_MAGIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) dont_measure fsmagic=0x1cd1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) dont_appraise fsmagic=0x1cd1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) # BINFMTFS_MAGIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) dont_measure fsmagic=0x42494e4d
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) dont_appraise fsmagic=0x42494e4d
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) # SECURITYFS_MAGIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) dont_measure fsmagic=0x73636673
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) dont_appraise fsmagic=0x73636673
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) # SELINUX_MAGIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) dont_measure fsmagic=0xf97cff8c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) dont_appraise fsmagic=0xf97cff8c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) # CGROUP_SUPER_MAGIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) dont_measure fsmagic=0x27e0eb
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) dont_appraise fsmagic=0x27e0eb
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) # NSFS_MAGIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) dont_measure fsmagic=0x6e736673
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) dont_appraise fsmagic=0x6e736673
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) measure func=BPRM_CHECK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) measure func=FILE_MMAP mask=MAY_EXEC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) measure func=FILE_CHECK mask=MAY_READ uid=0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) measure func=MODULE_CHECK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) measure func=FIRMWARE_CHECK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) appraise fowner=0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) The default policy measures all executables in bprm_check,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) all files mmapped executable in file_mmap, and all files
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) open for read by root in do_filp_open. The default appraisal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) policy appraises all files owned by root.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) Examples of LSM specific definitions:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) SELinux::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) dont_measure obj_type=var_log_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) dont_appraise obj_type=var_log_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) dont_measure obj_type=auditd_log_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) dont_appraise obj_type=auditd_log_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) measure subj_user=system_u func=FILE_CHECK mask=MAY_READ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) measure subj_role=system_r func=FILE_CHECK mask=MAY_READ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) Smack::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) measure subj_user=_ func=FILE_CHECK mask=MAY_READ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) Example of measure rules using alternate PCRs::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) measure func=KEXEC_KERNEL_CHECK pcr=4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) measure func=KEXEC_INITRAMFS_CHECK pcr=5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) Example of appraise rule allowing modsig appended signatures:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) appraise func=KEXEC_KERNEL_CHECK appraise_type=imasig|modsig
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) Example of measure rule using KEY_CHECK to measure all keys:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) measure func=KEY_CHECK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) Example of measure rule using KEY_CHECK to only measure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) keys added to .builtin_trusted_keys or .ima keyring:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) measure func=KEY_CHECK keyrings=.builtin_trusted_keys|.ima