@@ -586,7 +586,7 @@ SYSCALL_DEFINE3(trusted_for, const int, fd, const enum trusted_for_usage, usage,
mask | MAY_ACCESS);
if (!err)
- err = ima_trusted_for(f.file, usage);
+ err = security_trusted_for(f.file, usage);
out_fd:
fdput(f);
@@ -402,3 +402,6 @@ LSM_HOOK(void, LSM_RET_VOID, perf_event_free, struct perf_event *event)
LSM_HOOK(int, 0, perf_event_read, struct perf_event *event)
LSM_HOOK(int, 0, perf_event_write, struct perf_event *event)
#endif /* CONFIG_PERF_EVENTS */
+
+LSM_HOOK(int, 0, trusted_for, struct file *file,
+ const enum trusted_for_usage usage)
@@ -1557,6 +1557,12 @@
* Read perf_event security info if allowed.
* @perf_event_write:
* Write perf_event security info if allowed.
+ *
+ * Security hooks for trusted applications (e.g. interpreters)
+ *
+ * @trusted_for:
+ * Return kernel file integrity status to trusted application
+ *
*/
union security_list_options {
#define LSM_HOOK(RET, DEFAULT, NAME, ...) RET (*NAME)(__VA_ARGS__);
@@ -31,6 +31,7 @@
#include <linux/err.h>
#include <linux/string.h>
#include <linux/mm.h>
+#include <uapi/linux/trusted-for.h>
struct linux_binprm;
struct cred;
@@ -2038,4 +2039,15 @@ static inline int security_perf_event_write(struct perf_event *event)
#endif /* CONFIG_SECURITY */
#endif /* CONFIG_PERF_EVENTS */
+#ifdef CONFIG_SECURITY
+extern int security_trusted_for(struct file *file,
+ const enum trusted_for_usage usage);
+#else
+static int security_trusted_for(struct file *file,
+ const enum trusted_for_usage usage)
+{
+ return 0;
+}
+#endif /* CONFIG_SECURITY */
+
#endif /* ! __LINUX_SECURITY_H */
@@ -2625,3 +2625,13 @@ int security_perf_event_write(struct perf_event *event)
return call_int_hook(perf_event_write, 0, event);
}
#endif /* CONFIG_PERF_EVENTS */
+
+int security_trusted_for(struct file *file, const enum trusted_for_usage usage)
+{
+ int ret;
+
+ ret = call_int_hook(trusted_for, 0, file, usage);
+ if (ret)
+ return ret;
+ return ima_trusted_for(file, usage);
+}
Extend the trusted_for syscall to call the security_trusted_for hook, which calls registered LSMs and IMA, instead of calling IMA directly. Signed-off-by: Mimi Zohar <zohar@linux.ibm.com> --- Mickaƫl, Casey, assuming there is a need... fs/open.c | 2 +- include/linux/lsm_hook_defs.h | 3 +++ include/linux/lsm_hooks.h | 6 ++++++ include/linux/security.h | 12 ++++++++++++ security/security.c | 10 ++++++++++ 5 files changed, 32 insertions(+), 1 deletion(-)