ima_policy 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. What: /sys/kernel/security/*/ima/policy
  2. Date: May 2008
  3. Contact: Mimi Zohar <[email protected]>
  4. Description:
  5. The Trusted Computing Group(TCG) runtime Integrity
  6. Measurement Architecture(IMA) maintains a list of hash
  7. values of executables and other sensitive system files
  8. loaded into the run-time of this system. At runtime,
  9. the policy can be constrained based on LSM specific data.
  10. Policies are loaded into the securityfs file ima/policy
  11. by opening the file, writing the rules one at a time and
  12. then closing the file. The new policy takes effect after
  13. the file ima/policy is closed.
  14. IMA appraisal, if configured, uses these file measurements
  15. for local measurement appraisal.
  16. ::
  17. rule format: action [condition ...]
  18. action: measure | dont_measure | appraise | dont_appraise |
  19. audit | hash | dont_hash
  20. condition:= base | lsm [option]
  21. base: [[func=] [mask=] [fsmagic=] [fsuuid=] [fsname=]
  22. [uid=] [euid=] [gid=] [egid=]
  23. [fowner=] [fgroup=]]
  24. lsm: [[subj_user=] [subj_role=] [subj_type=]
  25. [obj_user=] [obj_role=] [obj_type=]]
  26. option: [digest_type=] [template=] [permit_directio]
  27. [appraise_type=] [appraise_flag=]
  28. [appraise_algos=] [keyrings=]
  29. base:
  30. func:= [BPRM_CHECK][MMAP_CHECK][CREDS_CHECK][FILE_CHECK][MODULE_CHECK]
  31. [FIRMWARE_CHECK]
  32. [KEXEC_KERNEL_CHECK] [KEXEC_INITRAMFS_CHECK]
  33. [KEXEC_CMDLINE] [KEY_CHECK] [CRITICAL_DATA]
  34. [SETXATTR_CHECK]
  35. mask:= [[^]MAY_READ] [[^]MAY_WRITE] [[^]MAY_APPEND]
  36. [[^]MAY_EXEC]
  37. fsmagic:= hex value
  38. fsuuid:= file system UUID (e.g 8bcbe394-4f13-4144-be8e-5aa9ea2ce2f6)
  39. uid:= decimal value
  40. euid:= decimal value
  41. gid:= decimal value
  42. egid:= decimal value
  43. fowner:= decimal value
  44. fgroup:= decimal value
  45. lsm: are LSM specific
  46. option:
  47. appraise_type:= [imasig] | [imasig|modsig] | [sigv3]
  48. where 'imasig' is the original or the signature
  49. format v2.
  50. where 'modsig' is an appended signature,
  51. where 'sigv3' is the signature format v3. (Currently
  52. limited to fsverity digest based signatures
  53. stored in security.ima xattr. Requires
  54. specifying "digest_type=verity" first.)
  55. appraise_flag:= [check_blacklist]
  56. Currently, blacklist check is only for files signed with appended
  57. signature.
  58. digest_type:= verity
  59. Require fs-verity's file digest instead of the
  60. regular IMA file hash.
  61. keyrings:= list of keyrings
  62. (eg, .builtin_trusted_keys|.ima). Only valid
  63. when action is "measure" and func is KEY_CHECK.
  64. template:= name of a defined IMA template type
  65. (eg, ima-ng). Only valid when action is "measure".
  66. pcr:= decimal value
  67. label:= [selinux]|[kernel_info]|[data_label]
  68. data_label:= a unique string used for grouping and limiting critical data.
  69. For example, "selinux" to measure critical data for SELinux.
  70. appraise_algos:= comma-separated list of hash algorithms
  71. For example, "sha256,sha512" to only accept to appraise
  72. files where the security.ima xattr was hashed with one
  73. of these two algorithms.
  74. default policy:
  75. # PROC_SUPER_MAGIC
  76. dont_measure fsmagic=0x9fa0
  77. dont_appraise fsmagic=0x9fa0
  78. # SYSFS_MAGIC
  79. dont_measure fsmagic=0x62656572
  80. dont_appraise fsmagic=0x62656572
  81. # DEBUGFS_MAGIC
  82. dont_measure fsmagic=0x64626720
  83. dont_appraise fsmagic=0x64626720
  84. # TMPFS_MAGIC
  85. dont_measure fsmagic=0x01021994
  86. dont_appraise fsmagic=0x01021994
  87. # RAMFS_MAGIC
  88. dont_appraise fsmagic=0x858458f6
  89. # DEVPTS_SUPER_MAGIC
  90. dont_measure fsmagic=0x1cd1
  91. dont_appraise fsmagic=0x1cd1
  92. # BINFMTFS_MAGIC
  93. dont_measure fsmagic=0x42494e4d
  94. dont_appraise fsmagic=0x42494e4d
  95. # SECURITYFS_MAGIC
  96. dont_measure fsmagic=0x73636673
  97. dont_appraise fsmagic=0x73636673
  98. # SELINUX_MAGIC
  99. dont_measure fsmagic=0xf97cff8c
  100. dont_appraise fsmagic=0xf97cff8c
  101. # CGROUP_SUPER_MAGIC
  102. dont_measure fsmagic=0x27e0eb
  103. dont_appraise fsmagic=0x27e0eb
  104. # NSFS_MAGIC
  105. dont_measure fsmagic=0x6e736673
  106. dont_appraise fsmagic=0x6e736673
  107. measure func=BPRM_CHECK
  108. measure func=FILE_MMAP mask=MAY_EXEC
  109. measure func=FILE_CHECK mask=MAY_READ uid=0
  110. measure func=MODULE_CHECK
  111. measure func=FIRMWARE_CHECK
  112. appraise fowner=0
  113. The default policy measures all executables in bprm_check,
  114. all files mmapped executable in file_mmap, and all files
  115. open for read by root in do_filp_open. The default appraisal
  116. policy appraises all files owned by root.
  117. Examples of LSM specific definitions:
  118. SELinux::
  119. dont_measure obj_type=var_log_t
  120. dont_appraise obj_type=var_log_t
  121. dont_measure obj_type=auditd_log_t
  122. dont_appraise obj_type=auditd_log_t
  123. measure subj_user=system_u func=FILE_CHECK mask=MAY_READ
  124. measure subj_role=system_r func=FILE_CHECK mask=MAY_READ
  125. Smack::
  126. measure subj_user=_ func=FILE_CHECK mask=MAY_READ
  127. Example of measure rules using alternate PCRs::
  128. measure func=KEXEC_KERNEL_CHECK pcr=4
  129. measure func=KEXEC_INITRAMFS_CHECK pcr=5
  130. Example of appraise rule allowing modsig appended signatures:
  131. appraise func=KEXEC_KERNEL_CHECK appraise_type=imasig|modsig
  132. Example of measure rule using KEY_CHECK to measure all keys:
  133. measure func=KEY_CHECK
  134. Example of measure rule using KEY_CHECK to only measure
  135. keys added to .builtin_trusted_keys or .ima keyring:
  136. measure func=KEY_CHECK keyrings=.builtin_trusted_keys|.ima
  137. Example of the special SETXATTR_CHECK appraise rule, that
  138. restricts the hash algorithms allowed when writing to the
  139. security.ima xattr of a file:
  140. appraise func=SETXATTR_CHECK appraise_algos=sha256,sha384,sha512
  141. Example of a 'measure' rule requiring fs-verity's digests
  142. with indication of type of digest in the measurement list.
  143. measure func=FILE_CHECK digest_type=verity \
  144. template=ima-ngv2
  145. Example of 'measure' and 'appraise' rules requiring fs-verity
  146. signatures (format version 3) stored in security.ima xattr.
  147. The 'measure' rule specifies the 'ima-sigv3' template option,
  148. which includes the indication of type of digest and the file
  149. signature in the measurement list.
  150. measure func=BPRM_CHECK digest_type=verity \
  151. template=ima-sigv3
  152. The 'appraise' rule specifies the type and signature format
  153. version (sigv3) required.
  154. appraise func=BPRM_CHECK digest_type=verity \
  155. appraise_type=sigv3
  156. All of these policy rules could, for example, be constrained
  157. either based on a filesystem's UUID (fsuuid) or based on LSM
  158. labels.