public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kylene Jo Hall <kjhall@us.ibm.com>
To: linux-kernel <linux-kernel@vger.kernel.org>,
	LSM ML <linux-security-module@vger.kernel.org>
Cc: Dave Safford <safford@us.ibm.com>, Mimi Zohar <zohar@us.ibm.com>,
	Serge Hallyn <sergeh@us.ibm.com>
Subject: [RFC][PATCH 4/6] slim: secfs patch
Date: Fri, 14 Jul 2006 10:24:42 -0700	[thread overview]
Message-ID: <1152897882.23584.7.camel@localhost.localdomain> (raw)

This patch provides the securityfs used by SLIM.

Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
Signed-off-by: Kylene Hall <kjhall@us.ibm.com>
--- 
 security/slim/slm_secfs.c |   73 ++++++++++++++++++++++++++++++++++++
 1 files changed, 73 insertions(+)

--- linux-2.6.17/security/slim/slm_secfs.c	1969-12-31 16:00:00.000000000 -0800
+++ linux-2.6.17/security/slim/slm_secfs.c	2006-07-13 16:28:17.000000000 -0700
@@ -0,0 +1,73 @@
+/*
+ * SLIM securityfs support: debugging control files
+ *
+ * Copyright (C) 2005, 2006 IBM Corporation
+ * Author: Mimi Zohar <zohar@us.ibm.com>
+ *	   Kylene Hall <kjhall@us.ibm.com>
+ *
+ *      This program is free software; you can redistribute it and/or modify
+ *      it under the terms of the GNU General Public License as published by
+ *      the Free Software Foundation, version 2 of the License.
+ */
+
+#include <asm/uaccess.h>
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/security.h>
+#include <linux/debugfs.h>
+#include "slim.h"
+
+static struct dentry *slim_sec_dir, *slim_level;
+
+static ssize_t slm_read_level(struct file *file, char __user *buf,
+			      size_t buflen, loff_t *ppos)
+{
+	struct slm_tsec_data *cur_tsec = current->security;
+	ssize_t len;
+	char *page = (char *)__get_free_page(GFP_KERNEL);
+	
+	if (!page)
+		return -ENOMEM;
+
+	if (is_kernel_thread(current))
+		len = sprintf(page, "level: KERNEL\n");
+	else if (!cur_tsec)
+		len = sprintf(page, "level: UNKNOWN\n");
+	else {
+		if (cur_tsec->iac_wx != cur_tsec->iac_r)
+			len = sprintf(page, "level: GUARD wx:%s r:%s\n",
+				      slm_iac_str[cur_tsec->iac_wx],
+				      slm_iac_str[cur_tsec->iac_r]);
+		else
+			len = sprintf(page, "level: %s\n",
+				      slm_iac_str[cur_tsec->iac_wx]);
+	}
+	len = simple_read_from_buffer(buf, buflen, ppos, page, len);
+	free_page((unsigned long)page);
+	return len;
+}
+
+static struct file_operations slm_level_ops = {
+	.read = slm_read_level,
+};
+
+int __init slm_init_secfs(void)
+{
+	slim_sec_dir = securityfs_create_dir("slim", NULL);
+	if (!slim_sec_dir || IS_ERR(slim_sec_dir))
+		return -EFAULT;
+	slim_level = securityfs_create_file("level", S_IRUGO,
+					    slim_sec_dir, NULL, &slm_level_ops);
+	if (!slim_level || IS_ERR(slim_level)) {
+		securityfs_remove(slim_sec_dir);
+		return -EFAULT;
+	}
+	return 0;
+}
+
+void __exit slm_cleanup_secfs(void)
+{
+	securityfs_remove(slim_level);
+	securityfs_remove(slim_sec_dir);
+}



             reply	other threads:[~2006-07-14 17:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-14 17:24 Kylene Jo Hall [this message]
2006-07-14 17:43 ` [RFC][PATCH 4/6] slim: secfs patch Dave Hansen
  -- strict thread matches above, loose matches on Subject: below --
2006-07-24 17:51 Kylene Jo Hall

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=1152897882.23584.7.camel@localhost.localdomain \
    --to=kjhall@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=safford@us.ibm.com \
    --cc=sergeh@us.ibm.com \
    --cc=zohar@us.ibm.com \
    /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