lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211014130125.6991-3-zohar@linux.ibm.com>
Date:   Thu, 14 Oct 2021 09:01:25 -0400
From:   Mimi Zohar <zohar@...ux.ibm.com>
To:     Mickaël Salaün <mic@...ikod.net>
Cc:     Mimi Zohar <zohar@...ux.ibm.com>,
        Al Viro <viro@...iv.linux.org.uk>,
        Andrew Morton <akpm@...ux-foundation.org>,
        linux-integrity@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-security-module@...r.kernel.org,
        Casey Schaufler <casey@...aufler-ca.com>
Subject: [PATCH v1 3/3] security: define a trusted_for hook

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@...ux.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(-)

diff --git a/fs/open.c b/fs/open.c
index 4d54e2a727e1..75336ca7020d 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -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);
diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h
index 2adeea44c0d5..f847fc0fd030 100644
--- a/include/linux/lsm_hook_defs.h
+++ b/include/linux/lsm_hook_defs.h
@@ -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)
diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h
index 5c4c5c0602cb..88e4f08f01ca 100644
--- a/include/linux/lsm_hooks.h
+++ b/include/linux/lsm_hooks.h
@@ -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__);
diff --git a/include/linux/security.h b/include/linux/security.h
index 5b7288521300..b067e22c8903 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -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 */
diff --git a/security/security.c b/security/security.c
index 9ffa9e9c5c55..f8e2a131d5cd 100644
--- a/security/security.c
+++ b/security/security.c
@@ -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);
+}
-- 
2.27.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ