Skip to contentSkip to conversation

integrity: SELinux patch

RFC In review Mimi Zohar 5 participants 13 messages Aug 28, 2007 – Sep 21, 2007 SELinux security module

lore
Share & tools
lore

Mimi Zohar

author
#0 lore raw

RFC 1/1 integrity: SELinux patch

This is a second attempt to verify and measure file integrity, by adding the new Linux Integrity Modules(LIM) API calls to SElinux. This posting addresses comments previously made on this list. I will also post the current set of LIM patches, as well as an initial integrity.te example.

The integrity of the SELinux metadata is verified when the xattr is initially retrieved. On an integrity failure, normal selinux error processing occurs.

This patch defines a new 'integrity' class with the permission 'measure'. Measurement calls are made in selinux_file_mmap(), selinux_bprm_check_security, and selinux_inode_permission(), based on policy. (Additional calls might be required.)

---

security/selinux/hooks.c +162 -31
Index: linux-2.6.23-rc3-mm1/security/selinux/hooks.c
===================================================================
@@ -69,6 +69,7 @@
 #include <linux/audit.h>
 #include <linux/string.h>
 #include <linux/selinux.h>
+#include <linux/integrity.h>
 #include <linux/mutex.h>
 
 #include "avc.h"
@@ -844,6 +845,7 @@ static int inode_doinit_with_dentry(stru
 	char *context = NULL;
 	unsigned len = 0;
 	int rc = 0;
+	int status;
 
 	if (isec->initialized)
 		goto out;
@@ -888,34 +890,12 @@ static int inode_doinit_with_dentry(stru
 		}
 
 		len = INITCONTEXTLEN;
-		context = kmalloc(len, GFP_KERNEL);
-		if (!context) {
-			rc = -ENOMEM;
+		rc = integrity_verify_metadata(dentry, XATTR_NAME_SELINUX,
+				       &context, &len, &status);
+		if (rc == -ENOMEM) {
 			dput(dentry);
 			goto out_unlock;
 		}
-		rc = inode->i_op->getxattr(dentry, XATTR_NAME_SELINUX,
-					   context, len);
-		if (rc == -ERANGE) {
-			/* Need a larger buffer.  Query for the right size. */
-			rc = inode->i_op->getxattr(dentry, XATTR_NAME_SELINUX,
-						   NULL, 0);
-			if (rc < 0) {
-				dput(dentry);
-				goto out_unlock;
-			}
-			kfree(context);
-			len = rc;
-			context = kmalloc(len, GFP_KERNEL);
-			if (!context) {
-				rc = -ENOMEM;
-				dput(dentry);
-				goto out_unlock;
-			}
-			rc = inode->i_op->getxattr(dentry,
-						   XATTR_NAME_SELINUX,
-						   context, len);
-		}
 		dput(dentry);
 		if (rc < 0) {
 			if (rc != -ENODATA) {
@@ -929,6 +909,14 @@ static int inode_doinit_with_dentry(stru
 			sid = sbsec->def_sid;
 			rc = 0;
 		} else {
+			if (status == INTEGRITY_FAIL) {
+				printk(KERN_WARNING "%s: verify_metadata "
+				       "failed for dev=%s ino=%ld\n",
+					__FUNCTION__,
+					inode->i_sb->s_id, inode->i_ino);
+				kfree(context);
+				goto out_unlock;
+			}
 			rc = security_context_to_sid_default(context, rc, &sid,
 			                                     sbsec->def_sid);
 			if (rc) {
@@ -1698,9 +1686,98 @@ static int selinux_bprm_set_security(str
 	return 0;
 }
 
-static int selinux_bprm_check_security (struct linux_binprm *bprm)
+static int selinux_verify_metadata(struct dentry *dentry)
 {
-	return secondary_ops->bprm_check_security(bprm);
+	int rc, status;
+
+	if (!dentry)
+		return 0;
+
+	rc = integrity_verify_metadata(dentry, NULL, NULL, NULL, &status);
+	if (rc == -EOPNOTSUPP)
+		return 0;
+	if (rc < 0)
+		goto out;
+
+	if (status != INTEGRITY_PASS) 	/* FAIL | NO_LABEL */
+		rc = -EACCES;
+out:
+	return rc;
+}
+
+static int selinux_verify_data(struct dentry *dentry, struct file *file)
+{
+	int rc, status;
+
+	if (!dentry && !file)
+		return 0;
+
+	rc = integrity_verify_data(dentry, file, &status);
+	if (rc < 0)
+		return 0;
+
+	if (status != INTEGRITY_PASS)
+		rc = -EACCES;
+
+	return rc;
+}
+
+/*
+ * Measure based on new 'integrity' class policy
+ */
+static void selinux_measure(struct inode *inode, struct dentry *dentry,
+				struct file *file, char *filename,
+				int mask)
+{
+	int rc = 1;
+	struct inode_security_struct *isec = inode->i_security;
+	struct task_security_struct *tsec = current->security;
+	struct av_decision avd;
+
+	if (!S_ISREG(inode->i_mode))
+		return;
+
+	rc = avc_has_perm_noaudit(tsec->sid, isec->sid, SECCLASS_INTEGRITY,
+				  INTEGRITY__MEASURE, AVC_STRICT, &avd);
+	if (rc == 0)
+		integrity_measure(inode, dentry, file, filename, mask);
+#if 0
+	else { /* Only used for debugging */
+		struct avc_audit_data ad;
+
+		AVC_AUDIT_DATA_INIT(&ad,FS);
+		ad.u.fs.mnt = NULL;
+		ad.u.fs.dentry = dentry;
+		avc_audit(tsec->sid, isec->sid, SECCLASS_INTEGRITY,
+			INTEGRITY__MEASURE, &avd, rc, &ad);
+	}
+#endif
+	return;
+}
+
+/* The OS protects against an executable file, already open for write,
+ * from being executed in deny_write_access() and an executable file
+ * already open for execute, from being modified in get_write_access().
+ * So we can be certain that what we verify and measure here is actually
+ * what is being executed.
+ */
+static int selinux_bprm_check_security(struct linux_binprm *bprm)
+{
+	struct dentry *dentry = bprm->file->f_dentry;
+	int rc;
+
+	rc = secondary_ops->bprm_check_security(bprm);
+	if (rc != 0)
+		return rc;
+
+	rc = selinux_verify_metadata(dentry);
+	if (rc == 0) {
+		rc = selinux_verify_data(dentry, bprm->file);
+		if (rc == 0)
+			selinux_measure(dentry->d_inode, dentry, bprm->file,
+					bprm->filename, MAY_EXEC);
+	}
+	return rc;
 }
 
 
@@ -2249,6 +2326,30 @@ static int selinux_inode_follow_link(str
 	return dentry_has_perm(current, NULL, dentry, FILE__READ);
 }
 
+static char *get_fname(struct dentry *dentry, struct vfsmount *mnt,
+			char **buf)
+{
+	char *fname = NULL;
+	char *path = NULL;
+
+	path = (char *)__get_free_page(GFP_KERNEL);
+	if (path) {
+		fname = d_path(dentry, mnt, path, PAGE_SIZE);
+		*buf = path;
+	}
+
+	if (!fname)	/* no choice, use short name */
+		fname = (!dentry->d_name.name) ?
+		    (char *)dentry->d_iname : (char *)dentry->d_name.name;
+	return fname;
+}
+
+static void free_fname(char *path)
+{
+	if (path)
+		free_page((unsigned long)path);
+}
+
 static int selinux_inode_permission(struct inode *inode, int mask,
 				    struct nameidata *nd)
 {
@@ -2263,8 +2364,29 @@ static int selinux_inode_permission(stru
 		return 0;
 	}
 
-	return inode_has_perm(current, inode,
+	rc = inode_has_perm(current, inode,
 			       file_mask_to_av(inode->i_mode, mask), NULL);
+	if (rc != 0)
+		return rc;
+
+	if (mask & ~MAY_EXEC) { /* measure executables later */
+		struct dentry *dentry = NULL;
+		char *path = NULL;
+		char *fname = NULL;
+
+		/* The file name is not required, but only a hint.
+		 * When possible, supply a fully qualified path name.
+		 */
+		if (nd) {
+			dentry = nd->dentry;
+			fname = get_fname(nd->dentry, nd->mnt, &path);
+		}
+
+		selinux_measure(inode, dentry, NULL, fname, mask);
+		if (path)
+			free_fname(path);
+	}
+	return rc;
 }
 
 static int selinux_inode_setattr(struct dentry *dentry, struct iattr *iattr)
@@ -2585,8 +2707,18 @@ static int selinux_file_mmap(struct file
 	if (selinux_checkreqprot)
 		prot = reqprot;
 
-	return file_map_prot_check(file, prot,
-				   (flags & MAP_TYPE) == MAP_SHARED);
+	rc = file_map_prot_check(file, prot, (flags & MAP_TYPE) == MAP_SHARED);
+	if (file && file->f_dentry && rc == 0) {
+		rc = selinux_verify_metadata(file->f_dentry);
+		if (rc == 0) {
+			rc = selinux_verify_data(NULL, file);
+			if (rc == 0)
+				selinux_measure(file->f_dentry->d_inode,
+						  file->f_dentry, file,
+						  NULL, MAY_EXEC);
+		}
+	}
+	return rc;
 }
 
 static int selinux_file_mprotect(struct vm_area_struct *vma,
@@ -2628,7 +2760,6 @@ static int selinux_file_mprotect(struct 
 			return rc;
 	}
 #endif
-
 	return file_map_prot_check(vma->vm_file, prot, vma->vm_flags&VM_SHARED);
 }
 
security/selinux/include/av_permissions.h +1 -0
Index: linux-2.6.23-rc3-mm1/security/selinux/include/av_permissions.h
===================================================================
@@ -824,3 +824,4 @@
 #define DCCP_SOCKET__NODE_BIND                    0x00400000UL
 #define DCCP_SOCKET__NAME_CONNECT                 0x00800000UL
 #define MEMPROTECT__MMAP_ZERO                     0x00000001UL
+#define INTEGRITY__MEASURE                        0x00000001UL
security/selinux/include/av_perm_to_string.h +1 -0
Index: linux-2.6.23-rc3-mm1/security/selinux/include/av_perm_to_string.h
===================================================================
@@ -159,3 +159,4 @@
    S_(SECCLASS_DCCP_SOCKET, DCCP_SOCKET__NODE_BIND, "node_bind")
    S_(SECCLASS_DCCP_SOCKET, DCCP_SOCKET__NAME_CONNECT, "name_connect")
    S_(SECCLASS_MEMPROTECT, MEMPROTECT__MMAP_ZERO, "mmap_zero")
+   S_(SECCLASS_INTEGRITY, INTEGRITY__MEASURE, "measure")
security/selinux/include/flask.h +1 -0
Index: linux-2.6.23-rc3-mm1/security/selinux/include/flask.h
===================================================================
@@ -50,6 +50,7 @@
 #define SECCLASS_KEY                                     58
 #define SECCLASS_DCCP_SOCKET                             60
 #define SECCLASS_MEMPROTECT                              61
+#define SECCLASS_INTEGRITY                               62
 
 /*
  * Security identifier indices for initial entities
security/selinux/include/class_to_string.h +1 -0
Index: linux-2.6.23-rc3-mm1/security/selinux/include/class_to_string.h
===================================================================
@@ -64,3 +64,4 @@
     S_(NULL)
     S_("dccp_socket")
     S_("memprotect")
+    S_("integrity")
security/selinux/ss/services.c +10 -6
Index: linux-2.6.23-rc3-mm1/security/selinux/ss/services.c
===================================================================
@@ -305,12 +305,12 @@ static int context_struct_compute_av(str
 		    tclass <= SECCLASS_NETLINK_DNRT_SOCKET)
 			tclass = SECCLASS_NETLINK_SOCKET;
 
-	if (!tclass || tclass > policydb.p_classes.nprim) {
-		printk(KERN_ERR "security_compute_av:  unrecognized class %d\n",
-		       tclass);
-		return -EINVAL;
-	}
-	tclass_datum = policydb.class_val_to_struct[tclass - 1];
+//	if (!tclass || tclass > policydb.p_classes.nprim) {
+//		printk(KERN_ERR "security_compute_av:  unrecognized class %d\n",
+//		       tclass);
+//		return -EINVAL;
+//	}
+//	tclass_datum = policydb.class_val_to_struct[tclass - 1];
 
 	/*
 	 * Initialize the access vectors to the default values.
@@ -321,6 +321,10 @@ static int context_struct_compute_av(str
 	avd->auditdeny = 0xffffffff;
 	avd->seqno = latest_granting;
 
+	if (!tclass || tclass > policydb.p_classes.nprim)
+		return 0;
+	tclass_datum = policydb.class_val_to_struct[tclass - 1];
+
 	/*
 	 * If a specific type enforcement rule was defined for
 	 * this permission check, then use it.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#1 lore raw
Quoted 29 lines · Mimi Zohar

This is a second attempt to verify and measure file integrity, by
adding the new Linux Integrity Modules(LIM) API calls to SElinux.
This posting addresses comments previously made on this list. I will also post the current set of LIM patches, as well as an initial integrity.te example.

The integrity of the SELinux metadata is verified when the xattr
is initially retrieved. On an integrity failure, normal selinux error processing occurs.

This patch defines a new 'integrity' class with the permission 'measure'. Measurement calls are made in selinux_file_mmap(), selinux_bprm_check_security, and selinux_inode_permission(), based on policy. (Additional calls might be required.)

<snip>

Index: linux-2.6.23-rc3-mm1/security/selinux/include/av_permissions.h
===================================================================

security/selinux/include/av_permissions.h +1 -0
@@ -824,3 +824,4 @@
 #define DCCP_SOCKET__NODE_BIND                    0x00400000UL
 #define DCCP_SOCKET__NAME_CONNECT                 0x00800000UL
 #define MEMPROTECT__MMAP_ZERO                     0x00000001UL
+#define INTEGRITY__MEASURE                        0x00000001UL

Index: linux-2.6.23-rc3-mm1/security/selinux/include/av_perm_to_string.h
===================================================================

security/selinux/include/av_perm_to_string.h line 162

Quoted 4 lines
security/selinux/include/av_perm_to_string.h +1 -0
@@ -159,3 +159,4 @@
    S_(SECCLASS_DCCP_SOCKET, DCCP_SOCKET__NODE_BIND, "node_bind")
    S_(SECCLASS_DCCP_SOCKET, DCCP_SOCKET__NAME_CONNECT, "name_connect")
    S_(SECCLASS_MEMPROTECT, MEMPROTECT__MMAP_ZERO, "mmap_zero")
+   S_(SECCLASS_INTEGRITY, INTEGRITY__MEASURE, "measure")

Do you really need another object class for this? What is wrong with the file object class? eg., a rule like:

allow insmod_t modules_object_t : file { read measure }; would require a measurement.

Quoted 33 lines

Index: linux-2.6.23-rc3-mm1/security/selinux/include/flask.h
===================================================================

security/selinux/include/flask.h +1 -0
@@ -50,6 +50,7 @@
 #define SECCLASS_KEY                                     58
 #define SECCLASS_DCCP_SOCKET                             60
 #define SECCLASS_MEMPROTECT                              61
+#define SECCLASS_INTEGRITY                               62
 
 /*
  * Security identifier indices for initial entities

Index: linux-2.6.23-rc3-mm1/security/selinux/include/class_to_string.h
===================================================================

security/selinux/include/class_to_string.h +1 -0
@@ -64,3 +64,4 @@
     S_(NULL)
     S_("dccp_socket")
     S_("memprotect")
+    S_("integrity")

Index: linux-2.6.23-rc3-mm1/security/selinux/ss/services.c
===================================================================

security/selinux/ss/services.c +0 -4
@@ -305,12 +305,12 @@ static int context_struct_compute_av(str
 		    tclass <= SECCLASS_NETLINK_DNRT_SOCKET)
 			tclass = SECCLASS_NETLINK_SOCKET;
 
-	if (!tclass || tclass > policydb.p_classes.nprim) {
-		printk(KERN_ERR "security_compute_av:  unrecognized class %d\n",
-		       tclass);
-		return -EINVAL;

security/selinux/ss/services.c static int context_struct_compute_av(str · line 315

Quoted 10 lines
security/selinux/ss/services.c +6 -2
-	}
-	tclass_datum = policydb.class_val_to_struct[tclass - 1];
+//	if (!tclass || tclass > policydb.p_classes.nprim) {
+//		printk(KERN_ERR "security_compute_av:  unrecognized class %d\n",
+//		       tclass);
+//		return -EINVAL;
+//	}
+//	tclass_datum = policydb.class_val_to_struct[tclass - 1];
 
 

Err? Did you mean to submit it like this? This should be fixed by Eric's patch to handle unknown classes anyway.

security/selinux/ss/services.c static int context_struct_compute_av(str · line 328

Quoted 11 lines
security/selinux/ss/services.c +0 -0
 	/*
security/selinux/ss/services.c +4 -0
 	 * Initialize the access vectors to the default values.
@@ -321,6 +321,10 @@ static int context_struct_compute_av(str
 	avd->auditdeny = 0xffffffff;
 	avd->seqno = latest_granting;
 
+	if (!tclass || tclass > policydb.p_classes.nprim)
+		return 0;
+	tclass_datum = policydb.class_val_to_struct[tclass - 1];
+
 

Ditto.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

author
#2 lore raw
Quoted 42 lines · Joshua Brindle
Quoted 33 lines · Mimi Zohar

This is a second attempt to verify and measure file integrity, by adding the new Linux Integrity Modules(LIM) API calls to SElinux. This posting addresses comments previously made on this list. I will also post the current set of LIM patches, as well as an initial integrity.te example.

The integrity of the SELinux metadata is verified when the xattr is initially retrieved. On an integrity failure, normal selinux error processing occurs.

This patch defines a new 'integrity' class with the permission 'measure'. Measurement calls are made in selinux_file_mmap(), selinux_bprm_check_security, and selinux_inode_permission(), based on policy. (Additional calls might be required.)

<snip>

Index: linux-2.6.23-rc3-mm1/security/selinux/include/av_permissions.h
===================================================================

security/selinux/include/av_permissions.h +1 -0
@@ -824,3 +824,4 @@
 #define DCCP_SOCKET__NODE_BIND                    0x00400000UL
 #define DCCP_SOCKET__NAME_CONNECT                 0x00800000UL
 #define MEMPROTECT__MMAP_ZERO                     0x00000001UL
+#define INTEGRITY__MEASURE                        0x00000001UL

Index: linux-2.6.23-rc3-mm1/security/selinux/include/av_perm_to_string.h
===================================================================

security/selinux/include/av_perm_to_string.h line 162

Quoted 4 lines
security/selinux/include/av_perm_to_string.h +1 -0
@@ -159,3 +159,4 @@
    S_(SECCLASS_DCCP_SOCKET, DCCP_SOCKET__NODE_BIND, "node_bind")
    S_(SECCLASS_DCCP_SOCKET, DCCP_SOCKET__NAME_CONNECT, "name_connect")
    S_(SECCLASS_MEMPROTECT, MEMPROTECT__MMAP_ZERO, "mmap_zero")
+   S_(SECCLASS_INTEGRITY, INTEGRITY__MEASURE, "measure")

Do you really need another object class for this? What is wrong with the file object class? eg., a rule like:

Quoted 2 lines

allow insmod_t modules_object_t : file { read measure }; would require a measurement.

The original version attempted to add file measure, but even without adding measure to the policy, files were being measured. The following is taken from Stephen's July 19th posting.

Quoted 52 lines
Quoted 10 lines
Quoted 6 lines

Unfortunately for you, policy uses "*" in allow rules for unconfined domains, and this means that your new permission is actually allowed by existing policies (because the policy compiler is just turning "*" into ~0UL and likewise turning "~{ a b c}" into the complement of that set, so the access vectors can have the bits turned on even if the permission wasn't defined yet.

Thank you for the explanation. At OLS, there was a suggestion to use avc_has_perm_noaudit(). As this is not measuring the appropriate files, do you, or anyone else, have any other recommendations?

Defining a new class for this purpose will free you from having any legacy policies implicitly granting the permission.

Quoted 38 lines

Index: linux-2.6.23-rc3-mm1/security/selinux/include/flask.h
===================================================================

security/selinux/include/flask.h +1 -0
@@ -50,6 +50,7 @@
 #define SECCLASS_KEY                                     58
 #define SECCLASS_DCCP_SOCKET                             60
 #define SECCLASS_MEMPROTECT                              61
+#define SECCLASS_INTEGRITY                               62
 
 /*
  * Security identifier indices for initial entities

Index: linux-2.6.23-rc3-mm1/security/selinux/include/class_to_string.h
===================================================================

security/selinux/include/class_to_string.h +1 -0
@@ -64,3 +64,4 @@
     S_(NULL)
     S_("dccp_socket")
     S_("memprotect")
+    S_("integrity")

Index: linux-2.6.23-rc3-mm1/security/selinux/ss/services.c
===================================================================

security/selinux/ss/services.c +3 -6
@@ -305,12 +305,12 @@ static int context_struct_compute_av(str
 		    tclass <= SECCLASS_NETLINK_DNRT_SOCKET)
 			tclass = SECCLASS_NETLINK_SOCKET;
 
-	if (!tclass || tclass > policydb.p_classes.nprim) {
-		printk(KERN_ERR "security_compute_av:  unrecognized class %d\n",
-		       tclass);
-		return -EINVAL;
-	}
-	tclass_datum = policydb.class_val_to_struct[tclass - 1];
+//	if (!tclass || tclass > policydb.p_classes.nprim) {
+//		printk(KERN_ERR "security_compute_av:  unrecognized class %d\n",
+//		       tclass);
Quoted 8 lines

security/selinux/ss/services.c static int context_struct_compute_av(str

Quoted 5 lines
security/selinux/ss/services.c +3 -0
+//		return -EINVAL;
+//	}
+//	tclass_datum = policydb.class_val_to_struct[tclass - 1];
 
 

Err? Did you mean to submit it like this? This should be fixed by Eric's patch to handle unknown classes anyway.

I'm working off the latest -mm tree and that patch hasn't made it in yet, as well as some other patches. For example, additional security class numbers have been defined. So I will need to update SECCLASS_INTEGRITY as well. The above code was added in order to test the patch. Once the basic integrity concept has been reviewed and accepted, I will repost based on the latest selinux development source tree.

Quoted 6 lines
Quoted 6 lines
security/selinux/ss/services.c +0 -0
 	/*
security/selinux/ss/services.c +0 -0
 	 * Initialize the access vectors to the default values.
@@ -321,6 +321,10 @@ static int context_struct_compute_av(str
 	avd->auditdeny = 0xffffffff;
 	avd->seqno = latest_granting;
 
Quoted 8 lines

security/selinux/ss/services.c static int context_struct_compute_av(str

Quoted 5 lines
security/selinux/ss/services.c +4 -0
+	if (!tclass || tclass > policydb.p_classes.nprim)
+		return 0;
+	tclass_datum = policydb.class_val_to_struct[tclass - 1];
+
 

Ditto.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#10 lore raw
In reply to Mimi Zohar
Quoted 6 lines · Mimi Zohar

This is a second attempt to verify and measure file integrity, by adding the new Linux Integrity Modules(LIM) API calls to SElinux. This posting addresses comments previously made on this list. I will also post the current set of LIM patches, as well as an initial integrity.te example.

Quoted 8 lines

The integrity of the SELinux metadata is verified when the xattr is initially retrieved. On an integrity failure, normal selinux error processing occurs.

This patch defines a new 'integrity' class with the permission 'measure'. Measurement calls are made in selinux_file_mmap(), selinux_bprm_check_security, and selinux_inode_permission(), based on policy. (Additional calls might be required.)

Just curious - wouldn't you want to also define a 'update' permission to allow policy to permit some domains to update xattrs? Or does that not make sense?

Quoted 23 lines

---
Index: linux-2.6.23-rc3-mm1/security/selinux/hooks.c
===================================================================

security/selinux/hooks.c +2 -0
@@ -69,6 +69,7 @@
 #include <linux/audit.h>
 #include <linux/string.h>
 #include <linux/selinux.h>
+#include <linux/integrity.h>
 #include <linux/mutex.h>
 
 #include "avc.h"
@@ -844,6 +845,7 @@ static int inode_doinit_with_dentry(stru
 	char *context = NULL;
 	unsigned len = 0;
 	int rc = 0;
+	int status;
 
 	if (isec->initialized)
 		goto out;

security/selinux/hooks.c static int inode_doinit_with_dentry(stru · line 894

Quoted 8 lines
security/selinux/hooks.c +2 -3
@@ -888,34 +890,12 @@ static int inode_doinit_with_dentry(stru
 		}
 
 		len = INITCONTEXTLEN;
-		context = kmalloc(len, GFP_KERNEL);
-		if (!context) {
-			rc = -ENOMEM;
+		rc = integrity_verify_metadata(dentry, XATTR_NAME_SELINUX,
+				       &context, &len, &status);

Hmm, so in this case shouldn't this be called integrity_get_and_verify_xattrs() or something? I guess that's too long, but I wouldn't have thought integrity_verify_metadata() would also get the xattrs.

Quoted 30 lines
security/selinux/hooks.c +1 -22
+		if (rc == -ENOMEM) {
 			dput(dentry);
 			goto out_unlock;
 		}
-		rc = inode->i_op->getxattr(dentry, XATTR_NAME_SELINUX,
-					   context, len);
-		if (rc == -ERANGE) {
-			/* Need a larger buffer.  Query for the right size. */
-			rc = inode->i_op->getxattr(dentry, XATTR_NAME_SELINUX,
-						   NULL, 0);
-			if (rc < 0) {
-				dput(dentry);
-				goto out_unlock;
-			}
-			kfree(context);
-			len = rc;
-			context = kmalloc(len, GFP_KERNEL);
-			if (!context) {
-				rc = -ENOMEM;
-				dput(dentry);
-				goto out_unlock;
-			}
-			rc = inode->i_op->getxattr(dentry,
-						   XATTR_NAME_SELINUX,
-						   context, len);
-		}
 		dput(dentry);
 		if (rc < 0) {
 			if (rc != -ENODATA) {

security/selinux/hooks.c static int inode_doinit_with_dentry(stru · line 916

Quoted 8 lines
security/selinux/hooks.c +5 -0
@@ -929,6 +909,14 @@ static int inode_doinit_with_dentry(stru
 			sid = sbsec->def_sid;
 			rc = 0;
 		} else {
+			if (status == INTEGRITY_FAIL) {
+				printk(KERN_WARNING "%s: verify_metadata "
+				       "failed for dev=%s ino=%ld\n",
+					__FUNCTION__,
+					inode->i_sb->s_id, inode->i_ino);

Seems like something worth using audit for.

Quoted 110 lines
security/selinux/hooks.c +94 -2
+				kfree(context);
+				goto out_unlock;
+			}
 			rc = security_context_to_sid_default(context, rc, &sid,
 			                                     sbsec->def_sid);
 			if (rc) {
@@ -1698,9 +1686,98 @@ static int selinux_bprm_set_security(str
 	return 0;
 }
 
-static int selinux_bprm_check_security (struct linux_binprm *bprm)
+static int selinux_verify_metadata(struct dentry *dentry)
 {
-	return secondary_ops->bprm_check_security(bprm);
+	int rc, status;
+
+	if (!dentry)
+		return 0;
+
+	rc = integrity_verify_metadata(dentry, NULL, NULL, NULL, &status);
+	if (rc == -EOPNOTSUPP)
+		return 0;
+	if (rc < 0)
+		goto out;
+
+	if (status != INTEGRITY_PASS) 	/* FAIL | NO_LABEL */
+		rc = -EACCES;
+out:
+	return rc;
+}
+
+static int selinux_verify_data(struct dentry *dentry, struct file *file)
+{
+	int rc, status;
+
+	if (!dentry && !file)
+		return 0;
+
+	rc = integrity_verify_data(dentry, file, &status);
+	if (rc < 0)
+		return 0;
+
+	if (status != INTEGRITY_PASS)
+		rc = -EACCES;
+
+	return rc;
+}
+
+/*
+ * Measure based on new 'integrity' class policy
+ */
+static void selinux_measure(struct inode *inode, struct dentry *dentry,
+				struct file *file, char *filename,
+				int mask)
+{
+	int rc = 1;
+	struct inode_security_struct *isec = inode->i_security;
+	struct task_security_struct *tsec = current->security;
+	struct av_decision avd;
+
+	if (!S_ISREG(inode->i_mode))
+		return;
+
+	rc = avc_has_perm_noaudit(tsec->sid, isec->sid, SECCLASS_INTEGRITY,
+				  INTEGRITY__MEASURE, AVC_STRICT, &avd);
+	if (rc == 0)
+		integrity_measure(inode, dentry, file, filename, mask);
+#if 0
+	else { /* Only used for debugging */
+		struct avc_audit_data ad;
+
+		AVC_AUDIT_DATA_INIT(&ad,FS);
+		ad.u.fs.mnt = NULL;
+		ad.u.fs.dentry = dentry;
+		avc_audit(tsec->sid, isec->sid, SECCLASS_INTEGRITY,
+			INTEGRITY__MEASURE, &avd, rc, &ad);
+	}
+#endif
+	return;
+}
+
+/* The OS protects against an executable file, already open for write,
+ * from being executed in deny_write_access() and an executable file
+ * already open for execute, from being modified in get_write_access().
+ * So we can be certain that what we verify and measure here is actually
+ * what is being executed.
+ */
+static int selinux_bprm_check_security(struct linux_binprm *bprm)
+{
+	struct dentry *dentry = bprm->file->f_dentry;
+	int rc;
+
+	rc = secondary_ops->bprm_check_security(bprm);
+	if (rc != 0)
+		return rc;
+
+	rc = selinux_verify_metadata(dentry);
+	if (rc == 0) {
+		rc = selinux_verify_data(dentry, bprm->file);
+		if (rc == 0)
+			selinux_measure(dentry->d_inode, dentry, bprm->file,
+					bprm->filename, MAY_EXEC);
+	}
+	return rc;
 }
 
 
@@ -2249,6 +2326,30 @@ static int selinux_inode_follow_link(str
 	return dentry_has_perm(current, NULL, dentry, FILE__READ);
 }

security/selinux/hooks.c static int selinux_inode_follow_link(str · line 2337

Quoted 10 lines
security/selinux/hooks.c +9 -0
 
+static char *get_fname(struct dentry *dentry, struct vfsmount *mnt,
+			char **buf)
+{
+	char *fname = NULL;
+	char *path = NULL;
+
+	path = (char *)__get_free_page(GFP_KERNEL);
+	if (path) {
+		fname = d_path(dentry, mnt, path, PAGE_SIZE);

Ok, this is kind of a drag performance-wise for something which is purely optional. How about putting this behind some boot or compile option or something?

Quoted 127 lines
security/selinux/hooks.c +49 -4
+		*buf = path;
+	}
+
+	if (!fname)	/* no choice, use short name */
+		fname = (!dentry->d_name.name) ?
+		    (char *)dentry->d_iname : (char *)dentry->d_name.name;
+	return fname;
+}
+
+static void free_fname(char *path)
+{
+	if (path)
+		free_page((unsigned long)path);
+}
+
 static int selinux_inode_permission(struct inode *inode, int mask,
 				    struct nameidata *nd)
 {
@@ -2263,8 +2364,29 @@ static int selinux_inode_permission(stru
 		return 0;
 	}
 
-	return inode_has_perm(current, inode,
+	rc = inode_has_perm(current, inode,
 			       file_mask_to_av(inode->i_mode, mask), NULL);
+	if (rc != 0)
+		return rc;
+
+	if (mask & ~MAY_EXEC) { /* measure executables later */
+		struct dentry *dentry = NULL;
+		char *path = NULL;
+		char *fname = NULL;
+
+		/* The file name is not required, but only a hint.
+		 * When possible, supply a fully qualified path name.
+		 */
+		if (nd) {
+			dentry = nd->dentry;
+			fname = get_fname(nd->dentry, nd->mnt, &path);
+		}
+
+		selinux_measure(inode, dentry, NULL, fname, mask);
+		if (path)
+			free_fname(path);
+	}
+	return rc;
 }
 
 static int selinux_inode_setattr(struct dentry *dentry, struct iattr *iattr)
@@ -2585,8 +2707,18 @@ static int selinux_file_mmap(struct file
 	if (selinux_checkreqprot)
 		prot = reqprot;
 
-	return file_map_prot_check(file, prot,
-				   (flags & MAP_TYPE) == MAP_SHARED);
+	rc = file_map_prot_check(file, prot, (flags & MAP_TYPE) == MAP_SHARED);
+	if (file && file->f_dentry && rc == 0) {
+		rc = selinux_verify_metadata(file->f_dentry);
+		if (rc == 0) {
+			rc = selinux_verify_data(NULL, file);
+			if (rc == 0)
+				selinux_measure(file->f_dentry->d_inode,
+						  file->f_dentry, file,
+						  NULL, MAY_EXEC);
+		}
+	}
+	return rc;
 }
 
 static int selinux_file_mprotect(struct vm_area_struct *vma,
@@ -2628,7 +2760,6 @@ static int selinux_file_mprotect(struct 
 			return rc;
 	}
 #endif
-
 	return file_map_prot_check(vma->vm_file, prot, vma->vm_flags&VM_SHARED);
 }
 

Index: linux-2.6.23-rc3-mm1/security/selinux/include/av_permissions.h
===================================================================

security/selinux/include/av_permissions.h +1 -0
@@ -824,3 +824,4 @@
 #define DCCP_SOCKET__NODE_BIND                    0x00400000UL
 #define DCCP_SOCKET__NAME_CONNECT                 0x00800000UL
 #define MEMPROTECT__MMAP_ZERO                     0x00000001UL
+#define INTEGRITY__MEASURE                        0x00000001UL

Index: linux-2.6.23-rc3-mm1/security/selinux/include/av_perm_to_string.h
===================================================================

security/selinux/include/av_perm_to_string.h +1 -0
@@ -159,3 +159,4 @@
    S_(SECCLASS_DCCP_SOCKET, DCCP_SOCKET__NODE_BIND, "node_bind")
    S_(SECCLASS_DCCP_SOCKET, DCCP_SOCKET__NAME_CONNECT, "name_connect")
    S_(SECCLASS_MEMPROTECT, MEMPROTECT__MMAP_ZERO, "mmap_zero")
+   S_(SECCLASS_INTEGRITY, INTEGRITY__MEASURE, "measure")

Index: linux-2.6.23-rc3-mm1/security/selinux/include/flask.h
===================================================================

security/selinux/include/flask.h +1 -0
@@ -50,6 +50,7 @@
 #define SECCLASS_KEY                                     58
 #define SECCLASS_DCCP_SOCKET                             60
 #define SECCLASS_MEMPROTECT                              61
+#define SECCLASS_INTEGRITY                               62
 
 /*
  * Security identifier indices for initial entities

Index: linux-2.6.23-rc3-mm1/security/selinux/include/class_to_string.h
===================================================================

security/selinux/include/class_to_string.h +1 -0
@@ -64,3 +64,4 @@
     S_(NULL)
     S_("dccp_socket")
     S_("memprotect")
+    S_("integrity")

Index: linux-2.6.23-rc3-mm1/security/selinux/ss/services.c
===================================================================

security/selinux/ss/services.c +0 -2
@@ -305,12 +305,12 @@ static int context_struct_compute_av(str
 		    tclass <= SECCLASS_NETLINK_DNRT_SOCKET)
 			tclass = SECCLASS_NETLINK_SOCKET;
 
-	if (!tclass || tclass > policydb.p_classes.nprim) {
-		printk(KERN_ERR "security_compute_av:  unrecognized class %d\n",

security/selinux/ss/services.c static int context_struct_compute_av(str · line 313

Quoted 10 lines
security/selinux/ss/services.c +6 -4
-		       tclass);
-		return -EINVAL;
-	}
-	tclass_datum = policydb.class_val_to_struct[tclass - 1];
+//	if (!tclass || tclass > policydb.p_classes.nprim) {
+//		printk(KERN_ERR "security_compute_av:  unrecognized class %d\n",
+//		       tclass);
+//		return -EINVAL;
+//	}
+//	tclass_datum = policydb.class_val_to_struct[tclass - 1];

As you can see the deletion is plenty obvious in the patch so please just delete it here rather than commenting it out :)

(As to the correctness of moving it I can't speak right now)

Quoted 18 lines
security/selinux/ss/services.c +4 -1
 	/*
 	 * Initialize the access vectors to the default values.
@@ -321,6 +321,10 @@ static int context_struct_compute_av(str
 	avd->auditdeny = 0xffffffff;
 	avd->seqno = latest_granting;
 
+	if (!tclass || tclass > policydb.p_classes.nprim)
+		return 0;
+	tclass_datum = policydb.class_val_to_struct[tclass - 1];
+
 	/*
 	 * If a specific type enforcement rule was defined for
 	 * this permission check, then use it.
 
 
 
--
Quoted 3 lines

This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#11 lore raw
Quoted 11 lines · Serge E. Hallyn
Quoted 10 lines · Mimi Zohar

This is a second attempt to verify and measure file integrity, by adding the new Linux Integrity Modules(LIM) API calls to SElinux. This posting addresses comments previously made on this list. I will also post the current set of LIM patches, as well as an initial integrity.te example.

The integrity of the SELinux metadata is verified when the xattr is initially retrieved. On an integrity failure, normal selinux error processing occurs.

Quoted 8 lines
Quoted 4 lines

This patch defines a new 'integrity' class with the permission 'measure'. Measurement calls are made in selinux_file_mmap(), selinux_bprm_check_security, and selinux_inode_permission(), based on policy. (Additional calls might be required.)

Just curious - wouldn't you want to also define a 'update' permission to allow policy to permit some domains to update xattrs? Or does that not make sense?

Oops, I see, that's what measure is... nm then.

-serge

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

author
#12 lore raw
Quoted 17 lines · Serge E. Hallyn
Quoted 16 lines · Serge E. Hallyn
Quoted 14 lines · Mimi Zohar

This is a second attempt to verify and measure file integrity, by adding the new Linux Integrity Modules(LIM) API calls to SElinux. This posting addresses comments previously made on this list. I will also post the current set of LIM patches, as well as an initial integrity.te example.

The integrity of the SELinux metadata is verified when the xattr is initially retrieved. On an integrity failure, normal selinux error processing occurs.

This patch defines a new 'integrity' class with the permission 'measure'. Measurement calls are made in selinux_file_mmap(), selinux_bprm_check_security, and selinux_inode_permission(), based on policy. (Additional calls might be required.)

Quoted 5 lines
Quoted 3 lines

Just curious - wouldn't you want to also define a 'update' permission to allow policy to permit some domains to update xattrs? Or does that not make sense?

Oops, I see, that's what measure is... nm then.

A LIM provider that implements integrity_verify_metadata/data would protect its own integrity xattrs, just as an LSM module protects its own xattrs, but that is not an SElinux issue. Based on a 'measure' policy, SELinux decides whether or not to add a measurement to the measurement list and extend the PCR value.

Mimi

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

author
#3 lore raw
In reply to Mimi Zohar
Quoted 29 lines · Mimi Zohar
Quoted 19 lines · Joshua Brindle
Quoted 17 lines · Mimi Zohar

Index: linux-2.6.23-rc3-mm1/security/selinux/ss/services.c
===================================================================

security/selinux/ss/services.c +3 -6
@@ -305,12 +305,12 @@ static int context_struct_compute_av(str
 		    tclass <= SECCLASS_NETLINK_DNRT_SOCKET)
 			tclass = SECCLASS_NETLINK_SOCKET;
 
-	if (!tclass || tclass > policydb.p_classes.nprim) {
-		printk(KERN_ERR "security_compute_av:  unrecognized class %d\n",
-		       tclass);
-		return -EINVAL;
-	}
-	tclass_datum = policydb.class_val_to_struct[tclass - 1];
+//	if (!tclass || tclass > policydb.p_classes.nprim) {
+//		printk(KERN_ERR "security_compute_av:  unrecognized class %d\n",
+//		       tclass);
Quoted 8 lines

security/selinux/ss/services.c static int context_struct_compute_av(str

Quoted 5 lines
security/selinux/ss/services.c +3 -0
+//		return -EINVAL;
+//	}
+//	tclass_datum = policydb.class_val_to_struct[tclass - 1];
 
 

Err? Did you mean to submit it like this? This should be fixed by Eric's patch to handle unknown classes anyway.

Quoted 6 lines

I'm working off the latest -mm tree and that patch hasn't made it in yet, as well as some other patches. For example, additional security class numbers have been defined. So I will need to update SECCLASS_INTEGRITY as well. The above code was added in order to test the patch. Once the basic integrity concept has been reviewed and accepted, I will repost based on the latest selinux development source tree.

Ok, so how do I get the latest selinux development source tree?

Thanks!

Mimi Zohar

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#4 lore raw
Quoted 30 lines · Mimi Zohar
Quoted 29 lines · Mimi Zohar
Quoted 27 lines · Joshua Brindle
Quoted 12 lines · Mimi Zohar

Index: linux-2.6.23-rc3-mm1/security/selinux/ss/services.c
===================================================================

security/selinux/ss/services.c +0 -4
@@ -305,12 +305,12 @@ static int context_struct_compute_av(str
 		    tclass <= SECCLASS_NETLINK_DNRT_SOCKET)
 			tclass = SECCLASS_NETLINK_SOCKET;
 
-	if (!tclass || tclass > policydb.p_classes.nprim) {
-		printk(KERN_ERR "security_compute_av:  unrecognized class %d\n",
-		       tclass);
-		return -EINVAL;

security/selinux/ss/services.c static int context_struct_compute_av(str · line 315

Quoted 10 lines
security/selinux/ss/services.c +6 -2
-	}
-	tclass_datum = policydb.class_val_to_struct[tclass - 1];
+//	if (!tclass || tclass > policydb.p_classes.nprim) {
+//		printk(KERN_ERR "security_compute_av:  unrecognized class %d\n",
+//		       tclass);
+//		return -EINVAL;
+//	}
+//	tclass_datum = policydb.class_val_to_struct[tclass - 1];
 
 

Err? Did you mean to submit it like this? This should be fixed by Eric's patch to handle unknown classes anyway.

Quoted 8 lines
Quoted 6 lines

I'm working off the latest -mm tree and that patch hasn't made it in yet, as well as some other patches. For example, additional security class numbers have been defined. So I will need to update SECCLASS_INTEGRITY as well. The above code was added in order to test the patch. Once the basic integrity concept has been reviewed and accepted, I will repost based on the latest selinux development source tree.

Ok, so how do I get the latest selinux development source tree?

James Morris maintains a selinux git tree on kernel.org, but even that wouldn't yet have Eric's patch (that patch has been posted a few times on list, but there are still a couple of changes to be made).

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
author
#5 lore raw
Quoted 38 lines · Stephen Smalley
Quoted 37 lines · Mimi Zohar
Quoted 35 lines · Mimi Zohar
Quoted 19 lines · Joshua Brindle
Quoted 17 lines · Mimi Zohar

Index: linux-2.6.23-rc3-mm1/security/selinux/ss/services.c
===================================================================

security/selinux/ss/services.c +3 -6
@@ -305,12 +305,12 @@ static int context_struct_compute_av(str
 		    tclass <= SECCLASS_NETLINK_DNRT_SOCKET)
 			tclass = SECCLASS_NETLINK_SOCKET;
 
-	if (!tclass || tclass > policydb.p_classes.nprim) {
-		printk(KERN_ERR "security_compute_av:  unrecognized class %d\n",
-		       tclass);
-		return -EINVAL;
-	}
-	tclass_datum = policydb.class_val_to_struct[tclass - 1];
+//	if (!tclass || tclass > policydb.p_classes.nprim) {
+//		printk(KERN_ERR "security_compute_av:  unrecognized class %d\n",
+//		       tclass);
Quoted 8 lines

security/selinux/ss/services.c static int context_struct_compute_av(str

Quoted 5 lines
security/selinux/ss/services.c +3 -0
+//		return -EINVAL;
+//	}
+//	tclass_datum = policydb.class_val_to_struct[tclass - 1];
 
 

Err? Did you mean to submit it like this? This should be fixed by Eric's patch to handle unknown classes anyway.

I'm working off the latest -mm tree and that patch hasn't made it in yet, as well as some other patches. For example, additional security class numbers have been defined. So I will need to update SECCLASS_INTEGRITY as well. The above code was added in order to test the patch. Once the basic integrity concept has been reviewed and accepted, I will repost based on the latest selinux development source tree.

Quoted 5 lines
Quoted 1 line

Ok, so how do I get the latest selinux development source tree?

James Morris maintains a selinux git tree on kernel.org, but even that wouldn't yet have Eric's patch (that patch has been posted a few times on list, but there are still a couple of changes to be made).

I could post a patch without commenting out the above lines, so that when Eric's patch does become available, there won't be any conflicts. That still leaves the issue of which number to use when extending the object class in security/selinux/include/flask.h for integrity. 62 is not assigned in either the latest -mm or -git, but didn't someone already post a patch on the SELinux mailing list using it?

Thanks!

Mimi Zohar

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#6 lore raw
Quoted 45 lines · Mimi Zohar
Quoted 38 lines · Stephen Smalley
Quoted 37 lines · Mimi Zohar
Quoted 35 lines · Mimi Zohar
Quoted 19 lines · Joshua Brindle
Quoted 17 lines · Mimi Zohar

Index: linux-2.6.23-rc3-mm1/security/selinux/ss/services.c
===================================================================

security/selinux/ss/services.c +3 -6
@@ -305,12 +305,12 @@ static int context_struct_compute_av(str
 		    tclass <= SECCLASS_NETLINK_DNRT_SOCKET)
 			tclass = SECCLASS_NETLINK_SOCKET;
 
-	if (!tclass || tclass > policydb.p_classes.nprim) {
-		printk(KERN_ERR "security_compute_av:  unrecognized class %d\n",
-		       tclass);
-		return -EINVAL;
-	}
-	tclass_datum = policydb.class_val_to_struct[tclass - 1];
+//	if (!tclass || tclass > policydb.p_classes.nprim) {
+//		printk(KERN_ERR "security_compute_av:  unrecognized class %d\n",
+//		       tclass);
Quoted 8 lines

security/selinux/ss/services.c static int context_struct_compute_av(str

Quoted 5 lines
security/selinux/ss/services.c +3 -0
+//		return -EINVAL;
+//	}
+//	tclass_datum = policydb.class_val_to_struct[tclass - 1];
 
 

Err? Did you mean to submit it like this? This should be fixed by Eric's patch to handle unknown classes anyway.

I'm working off the latest -mm tree and that patch hasn't made it in yet, as well as some other patches. For example, additional security class numbers have been defined. So I will need to update SECCLASS_INTEGRITY as well. The above code was added in order to test the patch. Once the basic integrity concept has been reviewed and accepted, I will repost based on the latest selinux development source tree.

Quoted 5 lines
Quoted 1 line

Ok, so how do I get the latest selinux development source tree?

James Morris maintains a selinux git tree on kernel.org, but even that wouldn't yet have Eric's patch (that patch has been posted a few times on list, but there are still a couple of changes to be made).

Quoted 6 lines

I could post a patch without commenting out the above lines, so that when Eric's patch does become available, there won't be any conflicts. That still leaves the issue of which number to use when extending the object class in security/selinux/include/flask.h for integrity. 62 is not assigned in either the latest -mm or -git, but didn't someone already post a patch on the SELinux mailing list using it?

Don't worry about conflicts with pending patches; just make a clean patch (where a clean patch follows the usual guidelines and doesn't include commented-out code) against some well-defined baseline (linus, mm, or selinux.git). Using the for-akpm branch of selinux.git makes it easier for James to merge of course, but as -mm includes that branch, it should be the same except as other patches in mm might happen to overlap and except as one happens to lag behind the other.

The capability override patch was using class 62, but that has not been merged and I wasn't planning on pushing it - there was a fair amount of concern about whether capability overrides are safe and usable as long as the distros have to allow selinux to be disabled as an option. So 62 is still available. More generally, class/perm values are not truly reserved until their definitions are committed, much like syscall values.

In any event, I don't think we are really at the point of just cleaning up implementation nits in these integrity patches - I think there needs to be more discussion and work on the overall design, hook placement and coverage, how it will be used in practice, who would use it, etc. Which goes beyond just how it would be integrated with selinux. I haven't really seen a compelling argument and concept of operations so far. As a general concept, I can see potential value in integrity measurement (although lots of pitfalls too), but I'm not sure that this approach is going to yield that value.

I had hoped that others more involved or interested in integrity measurement might have weighed in on the discussion (hint, hint).

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#7 lore raw
Quoted 7 lines · Stephen Smalley

Don't worry about conflicts with pending patches; just make a clean patch (where a clean patch follows the usual guidelines and doesn't include commented-out code) against some well-defined baseline (linus, mm, or selinux.git). Using the for-akpm branch of selinux.git makes it easier for James to merge of course, but as -mm includes that branch, it should be the same except as other patches in mm might happen to overlap and except as one happens to lag behind the other.

Generally, a patch against the latest Linus git will work fine, as that is what -mm is against, and if there are conflicts, they need to be resolved there anyway.

Signature · 7 lines
James Morris
<[email protected]>

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
author
#9 lore raw
In reply to Stephen Smalley
Quoted 10 lines · Stephen Smalley

In any event, I don't think we are really at the point of just cleaning up implementation nits in these integrity patches - I think there needs to be more discussion and work on the overall design, hook placement and coverage, how it will be used in practice, who would use it, etc. Which goes beyond just how it would be integrated with selinux. I haven't really seen a compelling argument and concept of operations so far. As a general concept, I can see potential value in integrity measurement (although lots of pitfalls too), but I'm not sure that this approach is going to yield that value.

Quoted 2 lines

I had hoped that others more involved or interested in integrity measurement might have weighed in on the discussion (hint, hint).

We were just about to post the latest LIM patches as an RFC to LMKL. If we can get a discussion going here first, that would be great. I will repost the latest set of patches.

In terms of design, the integrity provider would be responsible for maintaining file integrity information, which an LSM module could query via the LIM integrity_verify_metadata/data() API. For now, we are releasing an IMA-only integrity provider, which implements the LIM integrity_measure() API. When integrity_measure() is called, IMA submits the measurement (hash) of the file to the TPM chip, for inclusion in one of the chip's Platform Configuration Registers (PCR). IMA also keeps a list of all file names and hashes that have been submitted to the TPM, which can be viewed through securityfs.

We have a number of enterprise customers who use the old LSM based IMA
(http://sourceforge.net/projects/linux-ima). They use it to monitor file integrity and version level on large server farms. Their top two requests have been to get IMA off of LSM, so that they can use it with Selinux and AppArmor, and to get it upstream, so that it will be supported. These customers are using just the measurement/attestation portion of LIM. The verification of labels and data is more oriented to enterprise verification of configuration of the labels, and to protect clients and servers from off-line attacks.

This is a request for comments for updates to the LIM integrity service framework, previously accepted into -mm, an IMA-only integrity service provider, and a SELinux integrity patch.

Patch 1/4 integrity: LIM api, hooks, and dummy provider Patch 2/4 integrity: IMA service provider Patch 3/4 integrity: TPM internal kernel interface Patch 4/4 integrity: SELinux LIM calls

Mimi Zohar
David Safford

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

author
#8 lore raw
In reply to James Morris
Quoted 10 lines · James Morris
Quoted 7 lines · Stephen Smalley

Don't worry about conflicts with pending patches; just make a clean patch (where a clean patch follows the usual guidelines and doesn't include commented-out code) against some well-defined baseline (linus, mm, or selinux.git). Using the for-akpm branch of selinux.git makes it easier for James to merge of course, but as -mm includes that branch, it should be the same except as other patches in mm might happen to overlap and except as one happens to lag behind the other.

Quoted 3 lines

Generally, a patch against the latest Linus git will work fine, as that is what -mm is against, and if there are conflicts, they need to be resolved there anyway.

OK. Thank you for clarifying the process. As I still need to post the LIM patches based on the -mm tree to LKML, for this iteration the SELinux integrity patch will also be against the latest -mm. Once we are further along in the process, when the LIM patches are back in -mm, I will post a git compatible SELinux integrity patch.

Mimi Zohar

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.