IMA: add a policy option to restrict xattr hash algorithms on appraisal
authorTHOBY Simon <Simon.THOBY@viveris.fr>
Mon, 16 Aug 2021 08:11:00 +0000 (08:11 +0000)
committerMimi Zohar <zohar@linux.ibm.com>
Mon, 16 Aug 2021 21:33:07 +0000 (17:33 -0400)
commit583a80ae86b5ceb68119cfb9a37404cf22f6cc46
tree69a1369662423cbd98f3f39584633e7175d95c32
parent1624dc0086056c3a35fd34b0235bb1eb88c1c4d5
IMA: add a policy option to restrict xattr hash algorithms on appraisal

The kernel has the ability to restrict the set of hash algorithms it
accepts for the security.ima xattr when it appraises files.

Define a new IMA policy rule option "appraise_algos=", using the
mentioned mechanism to expose a user-toggable policy knob to opt-in
to that restriction and select the desired set of algorithms that
must be accepted.

When a policy rule uses the 'appraise_algos' option, appraisal of a
file referenced by that rule will now fail if the digest algorithm
employed to hash the file was not one of those explicitly listed in
the option.  In its absence, any hash algorithm compiled in the
kernel will be accepted.

For example, on a system where SELinux is properly deployed, the rule
appraise func=BPRM_CHECK obj_type=iptables_exec_t \
appraise_algos=sha256,sha384
will block the execution of iptables if the xattr security.ima of its
executables were not hashed with either sha256 or sha384.

Signed-off-by: THOBY Simon <Simon.THOBY@viveris.fr>
Reviewed-by: Lakshmi Ramasubramanian <nramas@linux.microsoft.com>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
Documentation/ABI/testing/ima_policy
security/integrity/ima/ima_policy.c