ima: add the ability to query the cached hash of a given file
authorFlorent Revest <revest@google.com>
Mon, 13 Jan 2020 09:42:44 +0000 (10:42 +0100)
committerMimi Zohar <zohar@linux.ibm.com>
Wed, 22 Jan 2020 20:22:51 +0000 (15:22 -0500)
commit6beea7afcc72b86986080ea1d228a42f2000f2a9
treef4dcbae6ca30de7fd291c6e84ee384bcfc0945d9
parent5350ceb0b7befba9f607fd4c09b1a424e117fe1c
ima: add the ability to query the cached hash of a given file

This allows other parts of the kernel (perhaps a stacked LSM allowing
system monitoring, eg. the proposed KRSI LSM [1]) to retrieve the hash
of a given file from IMA if it's present in the iint cache.

It's true that the existence of the hash means that it's also in the
audit logs or in /sys/kernel/security/ima/ascii_runtime_measurements,
but it can be difficult to pull that information out for every
subsequent exec. This is especially true if a given host has been up
for a long time and the file was first measured a long time ago.

It should be kept in mind that this function gives access to cached
entries which can be removed, for instance on security_inode_free().

This is based on Peter Moody's patch:
 https://sourceforge.net/p/linux-ima/mailman/message/33036180/

[1] https://lkml.org/lkml/2019/9/10/393

Signed-off-by: Florent Revest <revest@google.com>
Reviewed-by: KP Singh <kpsingh@chromium.org>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
include/linux/ima.h
security/integrity/ima/ima_main.c