From: Mimi Zohar <zohar@linux.ibm.com>
To: "Mickaël Salaün" <mic@digikod.net>
Cc: Mimi Zohar <zohar@linux.ibm.com>,
Al Viro <viro@zeniv.linux.org.uk>,
Andrew Morton <akpm@linux-foundation.org>,
linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-security-module@vger.kernel.org,
Casey Schaufler <casey@schaufler-ca.com>
Subject: [PATCH v1 3/3] security: define a trusted_for hook
Date: Thu, 14 Oct 2021 09:01:25 -0400 [thread overview]
Message-ID: <20211014130125.6991-3-zohar@linux.ibm.com> (raw)
In-Reply-To: <20211014130125.6991-1-zohar@linux.ibm.com>
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(-)
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
prev parent reply other threads:[~2021-10-14 13:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-14 13:01 [PATCH v1 1/3] ima: define ima_trusted_for hook Mimi Zohar
2021-10-14 13:01 ` [PATCH v1 2/3] fs: extend the trusted_for syscall to call IMA Mimi Zohar
2021-10-14 13:01 ` Mimi Zohar [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211014130125.6991-3-zohar@linux.ibm.com \
--to=zohar@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=casey@schaufler-ca.com \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=mic@digikod.net \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).