summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorEnrico Bravi <enrico.bravi@polito.it>2026-07-13 10:09:58 +0200
committerMimi Zohar <zohar@linux.ibm.com>2026-08-04 12:35:03 -0400
commitf1e10b10874051e4d99911dae0dd7b75a9f8ae66 (patch)
tree367332cb5c9f2f44df47c225670c4496cb54c48d /include/linux
parentf83a9cd9651344c12197bbbe07434228828f464f (diff)
ima: measure userspace policy writes before parsing
When a signed policy is not mandatory, userspace can write IMA policy rules directly to the securityfs policy file: echo -e "measure func=BPRM_CHECK mask=MAY_EXEC\n" \ "audit func=BPRM_CHECK mask=MAY_EXEC\n" \ > /sys/kernel/security/ima/policy or by cat'ing the entire IMA custom policy file: cat ima-policy-file > /sys/kernel/security/ima/policy Because these rules originate from userspace and cross the userspace/kernel trust boundary, measure the raw write buffer before parsing, regardless of whether the new policy will be accepted or not. This can be caught when 'measure func=POLICY_CHECK' is enabled (e.g., ima_policy=tcb). The measurement template is forced to ima-buf. This follows the "measure & load" paradigm, exposing potential bugs in the policy code and detecting attempts to corrupt IMA. It also completes the POLICY_CHECK hook, which already measures partial policy load by file. To verify the template data hash value, convert the buffer policy data to binary: grep "ima_policy_written" \ /sys/kernel/security/integrity/ima/ascii_runtime_measurements | \ tail -1 | cut -d' ' -f 6 | xxd -r -p | sha256sum Suggested-by: Roberto Sassu <roberto.sassu@huawei.com> Signed-off-by: Enrico Bravi <enrico.bravi@polito.it> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
Diffstat (limited to 'include/linux')
0 files changed, 0 insertions, 0 deletions