xref: /openbmc/linux/Documentation/ABI/testing/ima_policy (revision c900529f3d9161bfde5cca0754f83b4d3c3e0220)
118e49b30SMauro Carvalho ChehabWhat:		/sys/kernel/security/*/ima/policy
24af4662fSMimi ZoharDate:		May 2008
34af4662fSMimi ZoharContact:	Mimi Zohar <zohar@us.ibm.com>
44af4662fSMimi ZoharDescription:
54af4662fSMimi Zohar		The Trusted Computing Group(TCG) runtime Integrity
64af4662fSMimi Zohar		Measurement Architecture(IMA) maintains a list of hash
74af4662fSMimi Zohar		values of executables and other sensitive system files
84af4662fSMimi Zohar		loaded into the run-time of this system.  At runtime,
94af4662fSMimi Zohar		the policy can be constrained based on LSM specific data.
104af4662fSMimi Zohar		Policies are loaded into the securityfs file ima/policy
114af4662fSMimi Zohar		by opening the file, writing the rules one at a time and
124af4662fSMimi Zohar		then closing the file.  The new policy takes effect after
134af4662fSMimi Zohar		the file ima/policy is closed.
144af4662fSMimi Zohar
1507f6a794SMimi Zohar		IMA appraisal, if configured, uses these file measurements
1607f6a794SMimi Zohar		for local measurement appraisal.
1707f6a794SMimi Zohar
1834433332SMauro Carvalho Chehab		::
1934433332SMauro Carvalho Chehab
204af4662fSMimi Zohar		  rule format: action [condition ...]
214af4662fSMimi Zohar
22da1b0029SMimi Zohar		  action: measure | dont_measure | appraise | dont_appraise |
23da1b0029SMimi Zohar			  audit | hash | dont_hash
240e5a247cSDmitry Kasatkin		  condition:= base | lsm  [option]
2540224c41SCurtis Veit			base:	[[func=] [mask=] [fsmagic=] [fsuuid=] [fsname=]
2640224c41SCurtis Veit				[uid=] [euid=] [gid=] [egid=]
2740224c41SCurtis Veit				[fowner=] [fgroup=]]
284af4662fSMimi Zohar			lsm:	[[subj_user=] [subj_role=] [subj_type=]
294af4662fSMimi Zohar				 [obj_user=] [obj_role=] [obj_type=]]
3054f03916SMimi Zohar			option:	[digest_type=] [template=] [permit_directio]
3154f03916SMimi Zohar				[appraise_type=] [appraise_flag=]
3254f03916SMimi Zohar				[appraise_algos=] [keyrings=]
3334433332SMauro Carvalho Chehab		  base:
34c418eed8SMichael Weiß			func:= [BPRM_CHECK][MMAP_CHECK][CREDS_CHECK][FILE_CHECK][MODULE_CHECK]
355a9196d7SMimi Zohar				[FIRMWARE_CHECK]
36d9ddf077SMimi Zohar				[KEXEC_KERNEL_CHECK] [KEXEC_INITRAMFS_CHECK]
37c4e43aa2STushar Sugandhi				[KEXEC_CMDLINE] [KEY_CHECK] [CRITICAL_DATA]
384958db32SRoberto Sassu				[SETXATTR_CHECK][MMAP_CHECK_REQPROT]
394351c294SMimi Zohar			mask:= [[^]MAY_READ] [[^]MAY_WRITE] [[^]MAY_APPEND]
404351c294SMimi Zohar			       [[^]MAY_EXEC]
414af4662fSMimi Zohar			fsmagic:= hex value
4285865c1fSDmitry Kasatkin			fsuuid:= file system UUID (e.g 8bcbe394-4f13-4144-be8e-5aa9ea2ce2f6)
434af4662fSMimi Zohar			uid:= decimal value
44139069efSMimi Zohar			euid:= decimal value
4540224c41SCurtis Veit			gid:= decimal value
4640224c41SCurtis Veit			egid:= decimal value
4707f6a794SMimi Zohar			fowner:= decimal value
4840224c41SCurtis Veit			fgroup:= decimal value
494af4662fSMimi Zohar		  lsm:  are LSM specific
5034433332SMauro Carvalho Chehab		  option:
51398c42e2SMimi Zohar			appraise_type:= [imasig] | [imasig|modsig] | [sigv3]
52398c42e2SMimi Zohar			    where 'imasig' is the original or the signature
53398c42e2SMimi Zohar				format v2.
54398c42e2SMimi Zohar			    where 'modsig' is an appended signature,
55398c42e2SMimi Zohar			    where 'sigv3' is the signature format v3. (Currently
56398c42e2SMimi Zohar				limited to fsverity digest based signatures
57398c42e2SMimi Zohar				stored in security.ima xattr. Requires
58398c42e2SMimi Zohar				specifying "digest_type=verity" first.)
59398c42e2SMimi Zohar
60*f20765fdSEric Snowberg			appraise_flag:= [check_blacklist] (deprecated)
61*f20765fdSEric Snowberg			Setting the check_blacklist flag is no longer necessary.
62*f20765fdSEric Snowberg			All appraisal functions set it by default.
6354f03916SMimi Zohar			digest_type:= verity
6454f03916SMimi Zohar			    Require fs-verity's file digest instead of the
6554f03916SMimi Zohar			    regular IMA file hash.
66e9085e0aSLakshmi Ramasubramanian			keyrings:= list of keyrings
67e9085e0aSLakshmi Ramasubramanian			(eg, .builtin_trusted_keys|.ima). Only valid
68e9085e0aSLakshmi Ramasubramanian			when action is "measure" and func is KEY_CHECK.
6919453ce0SMatthew Garrett			template:= name of a defined IMA template type
7019453ce0SMatthew Garrett			(eg, ima-ng). Only valid when action is "measure".
71fc26bd50SEric Richter			pcr:= decimal value
72b3f82afcSRaphael Gianotti			label:= [selinux]|[kernel_info]|[data_label]
7347d76a48STushar Sugandhi			data_label:= a unique string used for grouping and limiting critical data.
74fdd1ffe8SLakshmi Ramasubramanian			For example, "selinux" to measure critical data for SELinux.
75583a80aeSTHOBY Simon			appraise_algos:= comma-separated list of hash algorithms
76583a80aeSTHOBY Simon			For example, "sha256,sha512" to only accept to appraise
77583a80aeSTHOBY Simon			files where the security.ima xattr was hashed with one
78583a80aeSTHOBY Simon			of these two algorithms.
794af4662fSMimi Zohar
804af4662fSMimi Zohar		  default policy:
814af4662fSMimi Zohar			# PROC_SUPER_MAGIC
824af4662fSMimi Zohar			dont_measure fsmagic=0x9fa0
8307f6a794SMimi Zohar			dont_appraise fsmagic=0x9fa0
844af4662fSMimi Zohar			# SYSFS_MAGIC
854af4662fSMimi Zohar			dont_measure fsmagic=0x62656572
8607f6a794SMimi Zohar			dont_appraise fsmagic=0x62656572
874af4662fSMimi Zohar			# DEBUGFS_MAGIC
884af4662fSMimi Zohar			dont_measure fsmagic=0x64626720
8907f6a794SMimi Zohar			dont_appraise fsmagic=0x64626720
904af4662fSMimi Zohar			# TMPFS_MAGIC
914af4662fSMimi Zohar			dont_measure fsmagic=0x01021994
9207f6a794SMimi Zohar			dont_appraise fsmagic=0x01021994
9307f6a794SMimi Zohar			# RAMFS_MAGIC
9407f6a794SMimi Zohar			dont_appraise fsmagic=0x858458f6
956438de9fSRoberto Sassu			# DEVPTS_SUPER_MAGIC
966438de9fSRoberto Sassu			dont_measure fsmagic=0x1cd1
976438de9fSRoberto Sassu			dont_appraise fsmagic=0x1cd1
986438de9fSRoberto Sassu			# BINFMTFS_MAGIC
996438de9fSRoberto Sassu			dont_measure fsmagic=0x42494e4d
1006438de9fSRoberto Sassu			dont_appraise fsmagic=0x42494e4d
1014af4662fSMimi Zohar			# SECURITYFS_MAGIC
1024af4662fSMimi Zohar			dont_measure fsmagic=0x73636673
10307f6a794SMimi Zohar			dont_appraise fsmagic=0x73636673
1046438de9fSRoberto Sassu			# SELINUX_MAGIC
1056438de9fSRoberto Sassu			dont_measure fsmagic=0xf97cff8c
1066438de9fSRoberto Sassu			dont_appraise fsmagic=0xf97cff8c
1076438de9fSRoberto Sassu			# CGROUP_SUPER_MAGIC
1086438de9fSRoberto Sassu			dont_measure fsmagic=0x27e0eb
1096438de9fSRoberto Sassu			dont_appraise fsmagic=0x27e0eb
110cd025f7fSMimi Zohar			# NSFS_MAGIC
111cd025f7fSMimi Zohar			dont_measure fsmagic=0x6e736673
112cd025f7fSMimi Zohar			dont_appraise fsmagic=0x6e736673
1134af4662fSMimi Zohar
1144af4662fSMimi Zohar			measure func=BPRM_CHECK
1154af4662fSMimi Zohar			measure func=FILE_MMAP mask=MAY_EXEC
1161e93d005SMimi Zohar			measure func=FILE_CHECK mask=MAY_READ uid=0
1175a9196d7SMimi Zohar			measure func=MODULE_CHECK
1185a9196d7SMimi Zohar			measure func=FIRMWARE_CHECK
11907f6a794SMimi Zohar			appraise fowner=0
1204af4662fSMimi Zohar
1214af4662fSMimi Zohar		The default policy measures all executables in bprm_check,
1224af4662fSMimi Zohar		all files mmapped executable in file_mmap, and all files
12307f6a794SMimi Zohar		open for read by root in do_filp_open.  The default appraisal
12407f6a794SMimi Zohar		policy appraises all files owned by root.
1254af4662fSMimi Zohar
1264af4662fSMimi Zohar		Examples of LSM specific definitions:
1274af4662fSMimi Zohar
12834433332SMauro Carvalho Chehab		SELinux::
12934433332SMauro Carvalho Chehab
1304af4662fSMimi Zohar			dont_measure obj_type=var_log_t
13107f6a794SMimi Zohar			dont_appraise obj_type=var_log_t
1324af4662fSMimi Zohar			dont_measure obj_type=auditd_log_t
13307f6a794SMimi Zohar			dont_appraise obj_type=auditd_log_t
1341e93d005SMimi Zohar			measure subj_user=system_u func=FILE_CHECK mask=MAY_READ
1351e93d005SMimi Zohar			measure subj_role=system_r func=FILE_CHECK mask=MAY_READ
1364af4662fSMimi Zohar
13734433332SMauro Carvalho Chehab		Smack::
13834433332SMauro Carvalho Chehab
1391e93d005SMimi Zohar			measure subj_user=_ func=FILE_CHECK mask=MAY_READ
140fc26bd50SEric Richter
14134433332SMauro Carvalho Chehab		Example of measure rules using alternate PCRs::
142fc26bd50SEric Richter
143fc26bd50SEric Richter			measure func=KEXEC_KERNEL_CHECK pcr=4
144fc26bd50SEric Richter			measure func=KEXEC_INITRAMFS_CHECK pcr=5
1459044d627SThiago Jung Bauermann
1469044d627SThiago Jung Bauermann		Example of appraise rule allowing modsig appended signatures:
1479044d627SThiago Jung Bauermann
1489044d627SThiago Jung Bauermann			appraise func=KEXEC_KERNEL_CHECK appraise_type=imasig|modsig
1495808611cSLakshmi Ramasubramanian
1505808611cSLakshmi Ramasubramanian		Example of measure rule using KEY_CHECK to measure all keys:
1515808611cSLakshmi Ramasubramanian
1525808611cSLakshmi Ramasubramanian			measure func=KEY_CHECK
153e9085e0aSLakshmi Ramasubramanian
154e9085e0aSLakshmi Ramasubramanian		Example of measure rule using KEY_CHECK to only measure
155e9085e0aSLakshmi Ramasubramanian		keys added to .builtin_trusted_keys or .ima keyring:
156e9085e0aSLakshmi Ramasubramanian
157e9085e0aSLakshmi Ramasubramanian			measure func=KEY_CHECK keyrings=.builtin_trusted_keys|.ima
1584f2946aaSTHOBY Simon
1594f2946aaSTHOBY Simon		Example of the special SETXATTR_CHECK appraise rule, that
1604f2946aaSTHOBY Simon		restricts the hash algorithms allowed when writing to the
1614f2946aaSTHOBY Simon		security.ima xattr of a file:
1624f2946aaSTHOBY Simon
1634f2946aaSTHOBY Simon			appraise func=SETXATTR_CHECK appraise_algos=sha256,sha384,sha512
16454f03916SMimi Zohar
16554f03916SMimi Zohar		Example of a 'measure' rule requiring fs-verity's digests
16654f03916SMimi Zohar		with indication of type of digest in the measurement list.
16754f03916SMimi Zohar
16854f03916SMimi Zohar			measure func=FILE_CHECK digest_type=verity \
16954f03916SMimi Zohar				template=ima-ngv2
170398c42e2SMimi Zohar
171398c42e2SMimi Zohar		Example of 'measure' and 'appraise' rules requiring fs-verity
172398c42e2SMimi Zohar		signatures (format version 3) stored in security.ima xattr.
173398c42e2SMimi Zohar
174398c42e2SMimi Zohar		The 'measure' rule specifies the 'ima-sigv3' template option,
175398c42e2SMimi Zohar		which includes the indication of type of digest and the file
176398c42e2SMimi Zohar		signature in the measurement list.
177398c42e2SMimi Zohar
178398c42e2SMimi Zohar			measure func=BPRM_CHECK digest_type=verity \
179398c42e2SMimi Zohar				template=ima-sigv3
180398c42e2SMimi Zohar
181398c42e2SMimi Zohar
182398c42e2SMimi Zohar		The 'appraise' rule specifies the type and signature format
183398c42e2SMimi Zohar		version (sigv3) required.
184398c42e2SMimi Zohar
185398c42e2SMimi Zohar			appraise func=BPRM_CHECK digest_type=verity \
186398c42e2SMimi Zohar				appraise_type=sigv3
187398c42e2SMimi Zohar
188398c42e2SMimi Zohar		All of these policy rules could, for example, be constrained
189398c42e2SMimi Zohar		either based on a filesystem's UUID (fsuuid) or based on LSM
190398c42e2SMimi Zohar		labels.
191