ima: Move comprehensive rule validation checks out of the token parser
authorTyler Hicks <tyhicks@linux.microsoft.com>
Thu, 9 Jul 2020 06:19:09 +0000 (01:19 -0500)
committerMimi Zohar <zohar@linux.ibm.com>
Mon, 20 Jul 2020 17:28:15 +0000 (13:28 -0400)
commit30031b0ec8aef903ebede41f43a8d021f0030499
tree38e042636b5c97028ff7746e68e48b64e8dc86d1
parentaa0c0227d331719052cf14a3c10e99a12818d81b
ima: Move comprehensive rule validation checks out of the token parser

Use ima_validate_rule(), at the end of the token parsing stage, to
verify combinations of actions, hooks, and flags. This is useful to
increase readability by consolidating such checks into a single function
and also because rule conditionals can be specified in arbitrary order
making it difficult to do comprehensive rule validation until the entire
rule has been parsed.

This allows for the check that ties together the "keyrings" conditional
with the KEY_CHECK function hook to be moved into the final rule
validation.

The modsig check no longer needs to compiled conditionally because the
token parser will ensure that modsig support is enabled before accepting
"imasig|modsig" appraise type values. The final rule validation will
ensure that appraise_type and appraise_flag options are only present in
appraise rules.

Finally, this allows for the check that ties together the "pcr"
conditional with the measure action to be moved into the final rule
validation.

Signed-off-by: Tyler Hicks <tyhicks@linux.microsoft.com>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
security/integrity/ima/ima.h
security/integrity/ima/ima_modsig.c
security/integrity/ima/ima_policy.c