From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
To: linux-security-module@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Subject: [PATCH 5/8] CaitSith: Add LSM adapter functions.
Date: Fri, 21 Oct 2016 21:49:07 +0900 [thread overview]
Message-ID: <1477054150-4772-6-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> (raw)
In-Reply-To: <1477054150-4772-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp>
This version implements only execve() related LSM hooks.
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
---
security/caitsith/lsm.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)
create mode 100644 security/caitsith/lsm.c
diff --git a/security/caitsith/lsm.c b/security/caitsith/lsm.c
new file mode 100644
index 0000000..675cee8
--- /dev/null
+++ b/security/caitsith/lsm.c
@@ -0,0 +1,60 @@
+/*
+ * security/caitsith/lsm.c
+ *
+ * Copyright (C) 2010-2013 Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
+ */
+
+#include <linux/lsm_hooks.h>
+#include "caitsith.h"
+
+/**
+ * caitsith_bprm_set_creds - Target for security_bprm_set_creds().
+ *
+ * @bprm: Pointer to "struct linux_binprm".
+ *
+ * Returns 0 on success, negative value otherwise.
+ */
+static int caitsith_bprm_set_creds(struct linux_binprm *bprm)
+{
+ /*
+ * Do only if this function is called for the first time of an execve
+ * operation.
+ */
+ if (bprm->cred_prepared)
+ return 0;
+#ifndef CONFIG_SECURITY_CAITSITH_OMIT_USERSPACE_LOADER
+ /*
+ * Load policy if /sbin/caitsith-init exists and /sbin/init is requested
+ * for the first time.
+ */
+ if (!cs_policy_loaded)
+ cs_load_policy(bprm->filename);
+#endif
+ return cs_start_execve(bprm);
+}
+
+/*
+ * caitsith_security_ops is a "struct security_operations" which is used for
+ * registering CaitSith.
+ */
+static struct security_hook_list caitsith_hooks[] = {
+ LSM_HOOK_INIT(bprm_set_creds, caitsith_bprm_set_creds),
+};
+
+/**
+ * caitsith_init - Register CaitSith as a LSM module.
+ *
+ * Returns 0.
+ */
+static int __init caitsith_init(void)
+{
+ if (!security_module_enable("caitsith"))
+ return 0;
+ /* register ourselves with the security framework */
+ security_add_hooks(caitsith_hooks, ARRAY_SIZE(caitsith_hooks));
+ printk(KERN_INFO "CaitSith initialized\n");
+ cs_init_module();
+ return 0;
+}
+
+security_initcall(caitsith_init);
--
1.8.3.1
next prev parent reply other threads:[~2016-10-21 12:50 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-21 12:49 [PATCH 0/8] CaitSith LSM module Tetsuo Handa
2016-10-21 12:49 ` [PATCH 1/8] CaitSith: Add header file Tetsuo Handa
2016-10-21 12:49 ` [PATCH 2/8] CaitSith: Add pathname calculation functions Tetsuo Handa
2016-10-21 12:49 ` [PATCH 3/8] CaitSith: Add policy I/O functions Tetsuo Handa
2016-10-21 12:49 ` [PATCH 4/8] CaitSith: Add permission check functions Tetsuo Handa
2016-10-21 12:49 ` Tetsuo Handa [this message]
2016-10-21 12:49 ` [PATCH 6/8] CaitSith: Add policy loader functions Tetsuo Handa
2016-10-21 12:49 ` [PATCH 7/8] CaitSith: Add garbage collector functions Tetsuo Handa
2016-10-21 12:49 ` [PATCH 8/8] CaitSith: Add Kconfig and Makefile Tetsuo Handa
2016-10-24 4:44 ` [PATCH 0/8] CaitSith LSM module James Morris
2016-10-24 14:39 ` John Johansen
2016-10-24 18:18 ` John Johansen
2016-10-25 11:26 ` Tetsuo Handa
2016-11-23 6:31 ` Tetsuo Handa
2016-11-23 18:51 ` John Johansen
2017-05-21 4:59 ` Tetsuo Handa
2017-05-21 5:31 ` John Johansen
2017-05-21 5:59 ` Tetsuo Handa
2017-10-21 10:59 ` Tetsuo Handa
2017-10-21 17:17 ` Casey Schaufler
2018-09-01 13:04 ` Tetsuo Handa
2018-09-05 16:22 ` John Johansen
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=1477054150-4772-6-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp \
--to=penguin-kernel@i-love.sakura.ne.jp \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
/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
all inboxes | Powered by JetHome®