Research
Skip Research Menus
Research MenuSecurity Enhanced Linux What's New Frequently Asked Questions Background Documents License Download Participating Mail List Archives Remaining Work Contributors Related Work Press Releases Information Assurance Research NIARL In-house Research Areas Mathematical Sciences Program Sabbaticals Computer & Information Sciences Research Technology Transfer Advanced Computing Advanced Mathematics Communications & Networking Information Processing Microelectronics Other Technologies Technology Fact Sheets Publications Related Links |
SELinux Mailing List[PATCH][SELINUX] add policyvers to selinuxfs
From: James Morris <jmorris_at_redhat.com>
Date: Mon, 6 Oct 2003 21:09:11 -0400 (EDT)
Please apply.
diff -urN -X dontdiff linux-2.6.0-test6-mm2.orig/security/selinux/include/security.h linux-2.6.0-test6-mm2.w1/security/selinux/include/security.h --- linux-2.6.0-test6-mm2.orig/security/selinux/include/security.h 2003-09-27 20:50:07.000000000 -0400 +++ linux-2.6.0-test6-mm2.w1/security/selinux/include/security.h 2003-10-03 15:06:59.901346808 -0400 @@ -13,6 +13,7 @@
#define SELINUX_MAGIC 0xf97cff8c
#ifdef CONFIG_SECURITY_SELINUX_BOOTPARAM --- linux-2.6.0-test6-mm2.orig/security/selinux/selinuxfs.c 2003-09-27 20:51:22.000000000 -0400 +++ linux-2.6.0-test6-mm2.w1/security/selinux/selinuxfs.c 2003-10-03 15:04:31.579895096 -0400 @@ -37,7 +37,8 @@ SEL_ACCESS, /* compute access decision */ SEL_CREATE, /* compute create labeling decision */ SEL_RELABEL, /* compute relabeling decision */ - SEL_USER /* compute reachable user contexts */ + SEL_USER, /* compute reachable user contexts */ + SEL_POLICYVERS /* return policy version for this kernel */}; static ssize_t sel_read_enforce(struct file *filp, char *buf, @@ -125,6 +126,46 @@
.write = sel_write_enforce,
+static ssize_t sel_read_policyvers(struct file *filp, char *buf, + size_t count, loff_t *ppos) +{ + char *page; + ssize_t length; + ssize_t end; + + if (count < 0 || count > PAGE_SIZE) + return -EINVAL; + if (!(page = (char*)__get_free_page(GFP_KERNEL))) + return -ENOMEM; + memset(page, 0, PAGE_SIZE); + + length = snprintf(page, PAGE_SIZE, "%u", POLICYDB_VERSION); + if (length < 0) { + free_page((unsigned long)page); + return length; + } + + if (*ppos >= length) { + free_page((unsigned long)page); + return 0; + } + if (count + *ppos > length) + count = length - *ppos; + end = count + *ppos; + if (copy_to_user(buf, (char *) page + *ppos, count)) { + count = -EFAULT; + goto out; + } + *ppos = end; +out: + free_page((unsigned long)page); + return count; +} + +static struct file_operations sel_policyvers_ops = { + .read = sel_read_policyvers, +}; + static ssize_t sel_write_load(struct file * file, const char * buf, size_t count, loff_t *ppos) @@ -568,6 +609,7 @@ [SEL_CREATE] = {"create", &transaction_ops, S_IRUGO|S_IWUGO}, [SEL_RELABEL] = {"relabel", &transaction_ops, S_IRUGO|S_IWUGO}, [SEL_USER] = {"user", &transaction_ops, S_IRUGO|S_IWUGO}, + [SEL_POLICYVERS] = {"policyvers", &sel_policyvers_ops, S_IRUGO}, /* last one */ {""} }; return simple_fill_super(sb, SELINUX_MAGIC, selinux_files); diff -urN -X dontdiff linux-2.6.0-test6-mm2.orig/security/selinux/ss/policydb.h linux-2.6.0-test6-mm2.w1/security/selinux/ss/policydb.h --- linux-2.6.0-test6-mm2.orig/security/selinux/ss/policydb.h 2003-09-27 20:50:38.000000000 -0400 +++ linux-2.6.0-test6-mm2.w1/security/selinux/ss/policydb.h 2003-10-03 15:06:59.291439528 -0400@@ -225,7 +225,6 @@
#define PERM_SYMTAB_SIZE 32
-#define POLICYDB_VERSION 15
#define OBJECT_R "object_r" -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with the words "unsubscribe selinux" without quotes as the message.Received on Mon 6 Oct 2003 - 21:09:12 EDT |
|
Date Posted: Jan 15, 2009 | Last Modified: Jan 15, 2009 | Last Reviewed: Jan 15, 2009 |