Blame SOURCES/libsepol-rhel.patch

979814
diff --git libsepol-2.5/Android.mk libsepol-2.5/Android.mk
979814
index a43b343..21c1af8 100644
979814
--- libsepol-2.5/Android.mk
979814
+++ libsepol-2.5/Android.mk
979814
@@ -68,10 +68,6 @@ common_cflags := \
979814
 	-Wshadow -Wmissing-noreturn \
979814
 	-Wmissing-format-attribute
979814
 
979814
-ifeq ($(HOST_OS), darwin)
979814
-common_cflags += -DDARWIN
979814
-endif
979814
-
979814
 common_includes := \
979814
 	$(LOCAL_PATH)/include/ \
979814
 	$(LOCAL_PATH)/src/ \
979814
diff --git libsepol-2.5/ChangeLog libsepol-2.5/ChangeLog
979814
index ace3d54..c7cc464 100644
979814
--- libsepol-2.5/ChangeLog
979814
+++ libsepol-2.5/ChangeLog
979814
@@ -1,3 +1,25 @@
979814
+	* Fix memory leak in expand.c, from William Roberts.
979814
+	* Fix invalid read when policy file is corrupt, from William Roberts.
979814
+	* Fix possible use of uninitialized variables, from William Roberts.
979814
+	* Warn instead of fail if permission is not resolved, from James Carter.
979814
+	* Ignore object_r when adding userrole mappings to policydb, from Steve Lawrence.
979814
+	* Add missing return to sepol_node_query(), from Petr Lautrbach.
979814
+	* Correctly detect unknown classes in sepol_string_to_security_class, from Joshua Brindle.
979814
+	* Sort object files for deterministic linking order, from Laurent Bigonville.
979814
+	* Fix neverallowxperm checking on attributes, from Jeff Vander Stoep.
979814
+	* Remove libsepol.map when cleaning, from Nicolas Iooss.
979814
+	* Add high-level language line marking support to CIL, from James Carter.
979814
+	* Change logic of bounds checking to match change in kernel, from James Carter.
979814
+	* Fix multiple spelling errors, from Laurent Bigonville.
979814
+	* Only apply bounds checking to source types in rules, from Stephen Smalley.
979814
+	* Fix CIL and not add an attribute as a type in the attr_type_map, from James Carter
979814
+	* Build policy on systems not supporting DCCP protocol, from Richard Haines.
979814
+	* Fix extended permissions neverallow checking, from Jeff Vander Stoep.
979814
+	* Fix CIL neverallow and bounds checking, from James Carter
979814
+	* Android.mk: Add -D_GNU_SOURCE to common_cflags, from Nick Kralevich.
979814
+	* Add support for portcon dccp protocol, from Richard Haines
979814
+	* Fix bug in CIL when resetting classes, from Steve Lawrence
979814
+
979814
 2.5 2016-02-23
979814
 	* Fix unused variable annotations, from Nicolas Iooss.
979814
 	* Fix uninitialized variable in CIL, from Nicolas Iooss.
979814
diff --git libsepol-2.5/cil/src/cil.c libsepol-2.5/cil/src/cil.c
979814
index afdc240..929ab19 100644
979814
--- libsepol-2.5/cil/src/cil.c
979814
+++ libsepol-2.5/cil/src/cil.c
979814
@@ -108,6 +108,7 @@ static void cil_init_keys(void)
979814
 	CIL_KEY_STAR = cil_strpool_add("*");
979814
 	CIL_KEY_UDP = cil_strpool_add("udp");
979814
 	CIL_KEY_TCP = cil_strpool_add("tcp");
979814
+	CIL_KEY_DCCP = cil_strpool_add("dccp");
979814
 	CIL_KEY_AUDITALLOW = cil_strpool_add("auditallow");
979814
 	CIL_KEY_TUNABLEIF = cil_strpool_add("tunableif");
979814
 	CIL_KEY_ALLOW = cil_strpool_add("allow");
979814
@@ -232,6 +233,9 @@ static void cil_init_keys(void)
979814
 	CIL_KEY_PERMISSIONX = cil_strpool_add("permissionx");
979814
 	CIL_KEY_IOCTL = cil_strpool_add("ioctl");
979814
 	CIL_KEY_UNORDERED = cil_strpool_add("unordered");
979814
+	CIL_KEY_SRC_INFO = cil_strpool_add("<src_info>");
979814
+	CIL_KEY_SRC_CIL = cil_strpool_add("<src_cil>");
979814
+	CIL_KEY_SRC_HLL = cil_strpool_add("<src_hll>");
979814
 }
979814
 
979814
 void cil_db_init(struct cil_db **db)
979814
@@ -756,6 +760,9 @@ void cil_destroy_data(void **data, enum cil_flavor flavor)
979814
 	case CIL_MLS:
979814
 		cil_destroy_mls(*data);
979814
 		break;
979814
+	case CIL_SRC_INFO:
979814
+		cil_destroy_src_info(*data);
979814
+		break;
979814
 	case CIL_OP:
979814
 	case CIL_CONS_OPERAND:
979814
 		break;
979814
@@ -763,8 +770,8 @@ void cil_destroy_data(void **data, enum cil_flavor flavor)
979814
 		cil_log(CIL_INFO, "Unknown data flavor: %d\n", flavor);
979814
 		break;
979814
 	}
979814
-	
979814
-	*data = NULL;		
979814
+
979814
+	*data = NULL;
979814
 }
979814
 
979814
 int cil_flavor_to_symtab_index(enum cil_flavor flavor, enum cil_sym_index *sym_index)
979814
@@ -1108,6 +1115,8 @@ const char * cil_node_to_string(struct cil_tree_node *node)
979814
 		return CIL_KEY_HANDLEUNKNOWN;
979814
 	case CIL_MLS:
979814
 		return CIL_KEY_MLS;
979814
+	case CIL_SRC_INFO:
979814
+		return CIL_KEY_SRC_INFO;
979814
 	case CIL_ALL:
979814
 		return CIL_KEY_ALL;
979814
 	case CIL_RANGE:
979814
@@ -1755,8 +1764,7 @@ int cil_get_symtab(struct cil_tree_node *ast_node, symtab_t **symtab, enum cil_s
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Failed to get symtab from node at line %d of %s\n",
979814
-			ast_node->line, ast_node->path);
979814
+	cil_tree_log(ast_node, CIL_ERR, "Failed to get symtab from node");
979814
 	return SEPOL_ERR;	
979814
 }
979814
 
979814
@@ -2553,3 +2561,10 @@ void cil_mls_init(struct cil_mls **mls)
979814
 	*mls = cil_malloc(sizeof(**mls));
979814
 	(*mls)->value = 0;
979814
 }
979814
+
979814
+void cil_src_info_init(struct cil_src_info **info)
979814
+{
979814
+	*info = cil_malloc(sizeof(**info));
979814
+	(*info)->is_cil = 0;
979814
+	(*info)->path = NULL;
979814
+}
979814
diff --git libsepol-2.5/cil/src/cil_binary.c libsepol-2.5/cil/src/cil_binary.c
979814
index f749e53..46fea4b 100644
979814
--- libsepol-2.5/cil/src/cil_binary.c
979814
+++ libsepol-2.5/cil/src/cil_binary.c
979814
@@ -31,6 +31,9 @@
979814
 #include <stdio.h>
979814
 #include <assert.h>
979814
 #include <netinet/in.h>
979814
+#ifndef IPPROTO_DCCP
979814
+#define IPPROTO_DCCP 33
979814
+#endif
979814
 
979814
 #include <sepol/policydb/policydb.h>
979814
 #include <sepol/policydb/polcaps.h>
979814
@@ -606,9 +609,11 @@ int __cil_typeattr_bitmap_init(policydb_t *pdb)
979814
 			rc = SEPOL_ERR;
979814
 			goto exit;
979814
 		}
979814
-		if (ebitmap_set_bit(&pdb->attr_type_map[i], i, 1)) {
979814
-			rc = SEPOL_ERR;
979814
-			goto exit;
979814
+		if (pdb->type_val_to_struct[i] && pdb->type_val_to_struct[i]->flavor != TYPE_ATTRIB) {
979814
+			if (ebitmap_set_bit(&pdb->attr_type_map[i], i, 1)) {
979814
+				rc = SEPOL_ERR;
979814
+				goto exit;
979814
+			}
979814
 		}
979814
 
979814
 	}
979814
@@ -749,6 +754,12 @@ int cil_userrole_to_policydb(policydb_t *pdb, const struct cil_db *db, struct ci
979814
 				goto exit;
979814
 			}
979814
 
979814
+			if (sepol_role->s.value == 1) {
979814
+				// role is object_r, ignore it since it is implicitly associated
979814
+				// with all users
979814
+				continue;
979814
+			}
979814
+
979814
 			if (ebitmap_set_bit(&sepol_user->roles.roles, sepol_role->s.value - 1, 1)) {
979814
 				cil_log(CIL_INFO, "Failed to set role bit for user\n");
979814
 				rc = SEPOL_ERR;
979814
@@ -1770,13 +1781,12 @@ int __cil_cond_to_policydb_helper(struct cil_tree_node *node, __attribute__((unu
979814
 		cil_typetrans = (struct cil_nametypetransition*)node->data;
979814
 		if (DATUM(cil_typetrans->name)->fqn != CIL_KEY_STAR) {
979814
 			cil_log(CIL_ERR, "typetransition with file name not allowed within a booleanif block.\n");
979814
-			cil_log(CIL_ERR,"Invalid typetransition statement at line %d of %s\n", 
979814
-			node->line, node->path);
979814
+			cil_tree_log(node, CIL_ERR,"Invalid typetransition statement");
979814
 			goto exit;
979814
 		}
979814
 		rc = __cil_typetransition_to_avtab(pdb, db, cil_typetrans, cond_node, cond_flavor, filename_trans_table);
979814
 		if (rc != SEPOL_OK) {
979814
-			cil_log(CIL_ERR, "Failed to insert type transition into avtab at line %d of %s\n", node->line, node->path);
979814
+			cil_tree_log(node, CIL_ERR, "Failed to insert type transition into avtab");
979814
 			goto exit;
979814
 		}
979814
 		break;
979814
@@ -1784,7 +1794,7 @@ int __cil_cond_to_policydb_helper(struct cil_tree_node *node, __attribute__((unu
979814
 		cil_type_rule = node->data;
979814
 		rc = __cil_type_rule_to_avtab(pdb, db, cil_type_rule, cond_node, cond_flavor);
979814
 		if (rc != SEPOL_OK) {
979814
-			cil_log(CIL_ERR, "Failed to insert typerule into avtab at line %d of %s\n", node->line, node->path);
979814
+			cil_tree_log(node, CIL_ERR, "Failed to insert typerule into avtab");
979814
 			goto exit;
979814
 		}
979814
 		break;
979814
@@ -1792,7 +1802,7 @@ int __cil_cond_to_policydb_helper(struct cil_tree_node *node, __attribute__((unu
979814
 		cil_avrule = node->data;
979814
 		rc = __cil_avrule_to_avtab(pdb, db, cil_avrule, cond_node, cond_flavor);
979814
 		if (rc != SEPOL_OK) {
979814
-			cil_log(CIL_ERR, "Failed to insert avrule into avtab at line %d of %s\n", node->line, node->path);
979814
+			cil_tree_log(node, CIL_ERR, "Failed to insert avrule into avtab");
979814
 			goto exit;
979814
 		}
979814
 		break;
979814
@@ -1800,8 +1810,7 @@ int __cil_cond_to_policydb_helper(struct cil_tree_node *node, __attribute__((unu
979814
 	case CIL_TUNABLEIF:
979814
 		break;
979814
 	default:
979814
-		cil_log(CIL_ERR, "Invalid statement within booleanif at line %d of %s\n", 
979814
-			node->line, node->path);
979814
+		cil_tree_log(node, CIL_ERR, "Invalid statement within booleanif");
979814
 		goto exit;
979814
 	}
979814
 
979814
@@ -2060,14 +2069,13 @@ int cil_booleanif_to_policydb(policydb_t *pdb, const struct cil_db *db, struct c
979814
 	tmp_cond = cond_node_create(pdb, NULL);
979814
 	if (tmp_cond == NULL) {
979814
 		rc = SEPOL_ERR;
979814
-		cil_log(CIL_INFO, "Failed to create sepol conditional node at line %d of %s\n", 
979814
-			node->line, node->path);
979814
+		cil_tree_log(node, CIL_INFO, "Failed to create sepol conditional node");
979814
 		goto exit;
979814
 	}
979814
 	
979814
 	rc = __cil_cond_expr_to_sepol_expr(pdb, cil_boolif->datum_expr, &tmp_cond->expr);
979814
 	if (rc != SEPOL_OK) {
979814
-		cil_log(CIL_INFO, "Failed to convert CIL conditional expression to sepol expression at line %d of %s\n", node->line, node->path);
979814
+		cil_tree_log(node, CIL_INFO, "Failed to convert CIL conditional expression to sepol expression");
979814
 		goto exit;
979814
 	}
979814
 
979814
@@ -2123,7 +2131,7 @@ int cil_booleanif_to_policydb(policydb_t *pdb, const struct cil_db *db, struct c
979814
 		bool_args.cond_flavor = CIL_CONDTRUE;
979814
 		rc = cil_tree_walk(true_node, __cil_cond_to_policydb_helper, NULL, NULL, &bool_args);
979814
 		if (rc != SEPOL_OK) {
979814
-			cil_log(CIL_ERR, "Failure while walking true conditional block at line %d of %s\n", true_node->line, true_node->path);
979814
+			cil_tree_log(true_node, CIL_ERR, "Failure while walking true conditional block");
979814
 			goto exit;
979814
 		}
979814
 	}
979814
@@ -2132,7 +2140,7 @@ int cil_booleanif_to_policydb(policydb_t *pdb, const struct cil_db *db, struct c
979814
 		bool_args.cond_flavor = CIL_CONDFALSE;
979814
 		rc = cil_tree_walk(false_node, __cil_cond_to_policydb_helper, NULL, NULL, &bool_args);
979814
 		if (rc != SEPOL_OK) {
979814
-			cil_log(CIL_ERR, "Failure while walking false conditional block at line %d of %s\n", false_node->line, false_node->path);
979814
+			cil_tree_log(false_node, CIL_ERR, "Failure while walking false conditional block");
979814
 			goto exit;
979814
 		}
979814
 	}
979814
@@ -3035,6 +3043,9 @@ int cil_portcon_to_policydb(policydb_t *pdb, struct cil_sort *portcons)
979814
 		case CIL_PROTOCOL_TCP:
979814
 			new_ocon->u.port.protocol = IPPROTO_TCP;
979814
 			break;
979814
+		case CIL_PROTOCOL_DCCP:
979814
+			new_ocon->u.port.protocol = IPPROTO_DCCP;
979814
+			break;
979814
 		default:
979814
 			/* should not get here */
979814
 			rc = SEPOL_ERR;
979814
@@ -3583,7 +3594,7 @@ int __cil_node_to_policydb(struct cil_tree_node *node, void *extra_args)
979814
 
979814
 exit:
979814
 	if (rc != SEPOL_OK) {
979814
-		cil_log(CIL_ERR, "Binary policy creation failed at line %d of %s\n", node->line, node->path);
979814
+		cil_tree_log(node, CIL_ERR, "Binary policy creation failed");
979814
 	}
979814
 	return rc;
979814
 }
979814
@@ -4227,6 +4238,9 @@ exit:
979814
 static avrule_t *__cil_init_sepol_avrule(uint32_t kind, struct cil_tree_node *node)
979814
 {
979814
 	avrule_t *avrule;
979814
+	struct cil_tree_node *source_node;
979814
+	char *source_path;
979814
+	int is_cil;
979814
 
979814
 	avrule = cil_malloc(sizeof(avrule_t));
979814
 	avrule->specified = kind;
979814
@@ -4235,8 +4249,17 @@ static avrule_t *__cil_init_sepol_avrule(uint32_t kind, struct cil_tree_node *no
979814
 	__cil_init_sepol_type_set(&avrule->ttypes);
979814
 	avrule->perms = NULL;
979814
 	avrule->line = node->line;
979814
-	avrule->source_filename = node->path;
979814
+
979814
+	avrule->source_filename = NULL;
979814
 	avrule->source_line = node->line;
979814
+	source_node = cil_tree_get_next_path(node, &source_path, &is_cil);
979814
+	if (source_node) {
979814
+		avrule->source_filename = source_path;
979814
+		if (!is_cil) {
979814
+			avrule->source_line = node->hll_line;
979814
+		}
979814
+	}
979814
+
979814
 	avrule->next = NULL;
979814
 	return avrule;
979814
 }
979814
@@ -4263,10 +4286,8 @@ static void __cil_print_parents(const char *pad, struct cil_tree_node *n)
979814
 
979814
 	__cil_print_parents(pad, n->parent);
979814
 
979814
-	if (!n->path) {
979814
-		cil_log(CIL_ERR,"%s%s\n", pad, cil_node_to_string(n));
979814
-	} else {
979814
-		cil_log(CIL_ERR,"%s%s at line %d of %s\n", pad, cil_node_to_string(n), n->line, n->path);
979814
+	if (n->flavor != CIL_SRC_INFO) {
979814
+		cil_tree_log(n, CIL_ERR,"%s%s", pad, cil_node_to_string(n));
979814
 	}
979814
 }
979814
 
979814
@@ -4357,7 +4378,7 @@ static int __cil_print_neverallow_failure(const struct cil_db *db, struct cil_tr
979814
 		allow_str = CIL_KEY_ALLOWX;
979814
 		avrule_flavor = CIL_AVRULEX;
979814
 	}
979814
-	cil_log(CIL_ERR, "%s check failed at line %d of %s\n", neverallow_str, node->line, node->path);
979814
+	cil_tree_log(node, CIL_ERR, "%s check failed", neverallow_str);
979814
 	__cil_print_rule("  ", neverallow_str, cil_rule);
979814
 	cil_list_init(&matching, CIL_NODE);
979814
 	rc = cil_find_matching_avrule_in_ast(db->ast->root, avrule_flavor, &target, matching, CIL_FALSE);
979814
@@ -4380,10 +4401,9 @@ exit:
979814
 	return rc;
979814
 }
979814
 
979814
-static int cil_check_neverallow(const struct cil_db *db, policydb_t *pdb, struct cil_tree_node *node)
979814
+static int cil_check_neverallow(const struct cil_db *db, policydb_t *pdb, struct cil_tree_node *node, int *violation)
979814
 {
979814
-	int rc = SEPOL_ERR;
979814
-	int ret = CIL_FALSE;
979814
+	int rc = SEPOL_OK;
979814
 	struct cil_avrule *cil_rule = node->data;
979814
 	struct cil_symtab_datum *tgt = cil_rule->tgt;
979814
 	uint32_t kind;
979814
@@ -4422,11 +4442,11 @@ static int cil_check_neverallow(const struct cil_db *db, policydb_t *pdb, struct
979814
 
979814
 		rc = check_assertion(pdb, rule);
979814
 		if (rc == CIL_TRUE) {
979814
+			*violation = CIL_TRUE;
979814
 			rc = __cil_print_neverallow_failure(db, node);
979814
 			if (rc != SEPOL_OK) {
979814
 				goto exit;
979814
 			}
979814
-			ret = CIL_TRUE;
979814
 		}
979814
 
979814
 	} else {
979814
@@ -4444,12 +4464,11 @@ static int cil_check_neverallow(const struct cil_db *db, policydb_t *pdb, struct
979814
 			rule->xperms = item->data;
979814
 			rc = check_assertion(pdb, rule);
979814
 			if (rc == CIL_TRUE) {
979814
+				*violation = CIL_TRUE;
979814
 				rc = __cil_print_neverallow_failure(db, node);
979814
 				if (rc != SEPOL_OK) {
979814
 					goto exit;
979814
 				}
979814
-				ret = CIL_TRUE;
979814
-				goto exit;
979814
 			}
979814
 		}
979814
 	}
979814
@@ -4466,34 +4485,23 @@ exit:
979814
 	rule->xperms = NULL;
979814
 	__cil_destroy_sepol_avrules(rule);
979814
 
979814
-	if (rc) {
979814
-		return rc;
979814
-	} else {
979814
-		return ret;
979814
-	}
979814
+	return rc;
979814
 }
979814
 
979814
-static int cil_check_neverallows(const struct cil_db *db, policydb_t *pdb, struct cil_list *neverallows)
979814
+static int cil_check_neverallows(const struct cil_db *db, policydb_t *pdb, struct cil_list *neverallows, int *violation)
979814
 {
979814
 	int rc = SEPOL_OK;
979814
-	int ret = CIL_FALSE;
979814
 	struct cil_list_item *item;
979814
 
979814
 	cil_list_for_each(item, neverallows) {
979814
-		rc = cil_check_neverallow(db, pdb, item->data);
979814
-		if (rc < 0) {
979814
+		rc = cil_check_neverallow(db, pdb, item->data, violation);
979814
+		if (rc != SEPOL_OK) {
979814
 			goto exit;
979814
-		} else if (rc > 0) {
979814
-			ret = CIL_TRUE;
979814
 		}
979814
 	}
979814
 
979814
 exit:
979814
-	if (rc || ret) {
979814
-		return SEPOL_ERR;
979814
-	} else {
979814
-		return SEPOL_OK;
979814
-	}
979814
+	return rc;
979814
 }
979814
 
979814
 static struct cil_list *cil_classperms_from_sepol(policydb_t *pdb, uint16_t class, uint32_t data, struct cil_class *class_value_to_cil[], struct cil_perm **perm_value_to_cil[])
979814
@@ -4548,7 +4556,7 @@ exit:
979814
 	return rc;
979814
 }
979814
 
979814
-static int cil_check_type_bounds(const struct cil_db *db, policydb_t *pdb, void *type_value_to_cil, struct cil_class *class_value_to_cil[], struct cil_perm **perm_value_to_cil[])
979814
+static int cil_check_type_bounds(const struct cil_db *db, policydb_t *pdb, void *type_value_to_cil, struct cil_class *class_value_to_cil[], struct cil_perm **perm_value_to_cil[], int *violation)
979814
 {
979814
 	int rc = SEPOL_OK;
979814
 	int i;
979814
@@ -4574,6 +4582,9 @@ static int cil_check_type_bounds(const struct cil_db *db, policydb_t *pdb, void
979814
 		if (bad) {
979814
 			avtab_ptr_t cur;
979814
 			struct cil_avrule target;
979814
+			struct cil_tree_node *n1 = NULL;
979814
+
979814
+			*violation = CIL_TRUE;
979814
 
979814
                         target.is_extended = 0;
979814
 			target.rule_kind = CIL_AVRULE_ALLOWED;
979814
@@ -4585,7 +4596,6 @@ static int cil_check_type_bounds(const struct cil_db *db, policydb_t *pdb, void
979814
 			for (cur = bad; cur; cur = cur->next) {
979814
 				struct cil_list_item *i2;
979814
 				struct cil_list *matching;
979814
-				struct cil_tree_node *n;
979814
 
979814
 				rc = cil_avrule_from_sepol(pdb, cur, &target, type_value_to_cil, class_value_to_cil, perm_value_to_cil);
979814
 				if (rc != SEPOL_OK) {
979814
@@ -4594,7 +4604,7 @@ static int cil_check_type_bounds(const struct cil_db *db, policydb_t *pdb, void
979814
 				}
979814
 				__cil_print_rule("  ", "allow", &target);
979814
 				cil_list_init(&matching, CIL_NODE);
979814
-				rc = cil_find_matching_avrule_in_ast(db->ast->root, CIL_AVRULE, &target, matching, CIL_FALSE);
979814
+				rc = cil_find_matching_avrule_in_ast(db->ast->root, CIL_AVRULE, &target, matching, CIL_TRUE);
979814
 				if (rc) {
979814
 					cil_log(CIL_ERR, "Error occurred while checking type bounds\n");
979814
 					cil_list_destroy(&matching, CIL_FALSE);
979814
@@ -4602,14 +4612,17 @@ static int cil_check_type_bounds(const struct cil_db *db, policydb_t *pdb, void
979814
 					bounds_destroy_bad(bad);
979814
 					goto exit;
979814
 				}
979814
-
979814
 				cil_list_for_each(i2, matching) {
979814
-					__cil_print_parents("    ", (struct cil_tree_node *)i2->data);
979814
+					struct cil_tree_node *n2 = i2->data;
979814
+					struct cil_avrule *r2 = n2->data;
979814
+					if (n1 == n2) {
979814
+						cil_log(CIL_ERR, "    <See previous>\n");
979814
+					} else {
979814
+						n1 = n2;
979814
+						__cil_print_parents("    ", n2);
979814
+						__cil_print_rule("      ", "allow", r2);
979814
+					}
979814
 				}
979814
-				i2 = matching->tail;
979814
-				n = i2->data;
979814
-				__cil_print_rule("      ", "allow", n->data);
979814
-				cil_log(CIL_ERR,"\n");
979814
 				cil_list_destroy(&matching, CIL_FALSE);
979814
 				cil_list_destroy(&target.perms.classperms, CIL_TRUE);
979814
 			}
979814
@@ -4753,20 +4766,32 @@ int cil_binary_create_allocated_pdb(const struct cil_db *db, sepol_policydb_t *p
979814
 	__cil_set_conditional_state_and_flags(pdb);
979814
 
979814
 	if (db->disable_neverallow != CIL_TRUE) {
979814
+		int violation = CIL_FALSE;
979814
 		cil_log(CIL_INFO, "Checking Neverallows\n");
979814
-		rc = cil_check_neverallows(db, pdb, neverallows);
979814
+		rc = cil_check_neverallows(db, pdb, neverallows, &violation);
979814
 		if (rc != SEPOL_OK) goto exit;
979814
 
979814
 		cil_log(CIL_INFO, "Checking User Bounds\n");
979814
-		bounds_check_users(NULL, pdb);
979814
+		rc = bounds_check_users(NULL, pdb);
979814
+		if (rc) {
979814
+			violation = CIL_TRUE;
979814
+		}
979814
 
979814
 		cil_log(CIL_INFO, "Checking Role Bounds\n");
979814
-		bounds_check_roles(NULL, pdb);
979814
+		rc = bounds_check_roles(NULL, pdb);
979814
+		if (rc) {
979814
+			violation = CIL_TRUE;
979814
+		}
979814
 
979814
 		cil_log(CIL_INFO, "Checking Type Bounds\n");
979814
-		rc = cil_check_type_bounds(db, pdb, type_value_to_cil, class_value_to_cil, perm_value_to_cil);
979814
+		rc = cil_check_type_bounds(db, pdb, type_value_to_cil, class_value_to_cil, perm_value_to_cil, &violation);
979814
 		if (rc != SEPOL_OK) goto exit;
979814
 
979814
+		if (violation == CIL_TRUE) {
979814
+			rc = SEPOL_ERR;
979814
+			goto exit;
979814
+		}
979814
+
979814
 	}
979814
 
979814
 	rc = SEPOL_OK;
979814
diff --git libsepol-2.5/cil/src/cil_build_ast.c libsepol-2.5/cil/src/cil_build_ast.c
979814
index 1135e06..1505873 100644
979814
--- libsepol-2.5/cil/src/cil_build_ast.c
979814
+++ libsepol-2.5/cil/src/cil_build_ast.c
979814
@@ -108,8 +108,7 @@ int cil_gen_node(__attribute__((unused)) struct cil_db *db, struct cil_tree_node
979814
 			if (cil_symtab_get_datum(symtab, key, &datum) == SEPOL_OK) {
979814
 				if (sflavor == CIL_SYM_BLOCKS) {
979814
 					struct cil_tree_node *node = datum->nodes->head->data;
979814
-					cil_log(CIL_ERR, "Previous declaration at line %d of %s\n",
979814
-						node->line, node->path);
979814
+					cil_tree_log(node, CIL_ERR, "Previous declaration");
979814
 				}
979814
 			}
979814
 			goto exit;
979814
@@ -186,8 +185,7 @@ int cil_gen_block(struct cil_db *db, struct cil_tree_node *parse_current, struct
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad block declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad block declaration");
979814
 	cil_destroy_block(block);
979814
 	cil_clear_node(ast_node);
979814
 	return rc;
979814
@@ -236,8 +234,7 @@ int cil_gen_blockinherit(struct cil_db *db, struct cil_tree_node *parse_current,
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad blockinherit declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad blockinherit declaration");
979814
 	cil_destroy_blockinherit(inherit);
979814
 	return rc;
979814
 }
979814
@@ -281,8 +278,7 @@ int cil_gen_blockabstract(struct cil_db *db, struct cil_tree_node *parse_current
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad blockabstract declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad blockabstract declaration");
979814
 	cil_destroy_blockabstract(abstract);
979814
 	return rc;
979814
 }
979814
@@ -326,8 +322,7 @@ int cil_gen_in(struct cil_db *db, struct cil_tree_node *parse_current, struct ci
979814
 
979814
 	return SEPOL_OK;
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad in statement at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad in statement");
979814
 	cil_destroy_in(in);
979814
 	return rc;
979814
 }
979814
@@ -387,8 +382,7 @@ int cil_gen_class(struct cil_db *db, struct cil_tree_node *parse_current, struct
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad class declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad class declaration");
979814
 	cil_destroy_class(class);
979814
 	cil_clear_node(ast_node);
979814
 	return rc;
979814
@@ -456,8 +450,7 @@ int cil_gen_classorder(struct cil_db *db, struct cil_tree_node *parse_current, s
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad classorder declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad classorder declaration");
979814
 	cil_destroy_classorder(classorder);
979814
 	return rc;
979814
 }
979814
@@ -527,7 +520,7 @@ int cil_gen_perm_nodes(struct cil_db *db, struct cil_tree_node *current_perm, st
979814
 		cil_tree_node_init(&new_ast);
979814
 		new_ast->parent = ast_node;
979814
 		new_ast->line = current_perm->line;
979814
-		new_ast->path = current_perm->path;
979814
+		new_ast->hll_line = current_perm->hll_line;
979814
 
979814
 		rc = cil_gen_perm(db, current_perm, new_ast, flavor, num_perms);
979814
 		if (rc != SEPOL_OK) {
979814
@@ -738,8 +731,7 @@ int cil_gen_classpermission(struct cil_db *db, struct cil_tree_node *parse_curre
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad classpermission declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad classpermission declaration");
979814
 	cil_destroy_classpermission(cp);
979814
 	cil_clear_node(ast_node);
979814
 	return rc;
979814
@@ -800,8 +792,7 @@ int cil_gen_classpermissionset(struct cil_db *db, struct cil_tree_node *parse_cu
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad classpermissionset at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad classpermissionset");
979814
 	cil_destroy_classpermissionset(cps);
979814
 	return rc;
979814
 }
979814
@@ -852,8 +843,7 @@ int cil_gen_map_class(struct cil_db *db, struct cil_tree_node *parse_current, st
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad map class declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad map class declaration");
979814
 	cil_destroy_class(map);
979814
 	cil_clear_node(ast_node);
979814
 	return rc;
979814
@@ -897,8 +887,7 @@ int cil_gen_classmapping(struct cil_db *db, struct cil_tree_node *parse_current,
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad classmapping declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad classmapping declaration");
979814
 	cil_destroy_classmapping(mapping);
979814
 	return rc;
979814
 }
979814
@@ -954,8 +943,7 @@ int cil_gen_common(struct cil_db *db, struct cil_tree_node *parse_current, struc
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad common declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad common declaration");
979814
 	cil_destroy_class(common);
979814
 	cil_clear_node(ast_node);
979814
 	return rc;
979814
@@ -994,8 +982,7 @@ int cil_gen_classcommon(struct cil_db *db, struct cil_tree_node *parse_current,
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad classcommon declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad classcommon declaration");
979814
 	cil_destroy_classcommon(clscom);
979814
 	return rc;
979814
 
979814
@@ -1043,8 +1030,7 @@ int cil_gen_sid(struct cil_db *db, struct cil_tree_node *parse_current, struct c
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad sid declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad sid declaration");
979814
 	cil_destroy_sid(sid);
979814
 	cil_clear_node(ast_node);
979814
 	return rc;
979814
@@ -1102,8 +1088,7 @@ int cil_gen_sidcontext(struct cil_db *db, struct cil_tree_node *parse_current, s
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad sidcontext declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad sidcontext declaration");
979814
 	cil_destroy_sidcontext(sidcon);
979814
 	return rc;
979814
 }
979814
@@ -1163,8 +1148,7 @@ int cil_gen_sidorder(struct cil_db *db, struct cil_tree_node *parse_current, str
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad sidorder declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad sidorder declaration");
979814
 	cil_destroy_sidorder(sidorder);
979814
 	return rc;
979814
 }
979814
@@ -1215,8 +1199,7 @@ int cil_gen_user(struct cil_db *db, struct cil_tree_node *parse_current, struct
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad user declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad user declaration");
979814
 	cil_destroy_user(user);
979814
 	cil_clear_node(ast_node);
979814
 	return rc;
979814
@@ -1265,8 +1248,7 @@ int cil_gen_userattribute(struct cil_db *db, struct cil_tree_node *parse_current
979814
 
979814
 	return SEPOL_OK;
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad userattribute declaration at line %d of %s\n",
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad userattribute declaration");
979814
 	cil_destroy_userattribute(attr);
979814
 	cil_clear_node(ast_node);
979814
 	return rc;
979814
@@ -1336,8 +1318,7 @@ int cil_gen_userattributeset(struct cil_db *db, struct cil_tree_node *parse_curr
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad userattributeset declaration at line %d of %s\n",
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad userattributeset declaration");
979814
 	cil_destroy_userattributeset(attrset);
979814
 
979814
 	return rc;
979814
@@ -1397,8 +1378,7 @@ int cil_gen_userlevel(struct cil_db *db, struct cil_tree_node *parse_current, st
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad userlevel declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad userlevel declaration");
979814
 	cil_destroy_userlevel(usrlvl);
979814
 	return rc;
979814
 }
979814
@@ -1458,8 +1438,7 @@ int cil_gen_userrange(struct cil_db *db, struct cil_tree_node *parse_current, st
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad userrange declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad userrange declaration");
979814
 	cil_destroy_userrange(userrange);
979814
 	return rc;
979814
 }
979814
@@ -1508,8 +1487,7 @@ int cil_gen_userprefix(struct cil_db *db, struct cil_tree_node *parse_current, s
979814
 
979814
 	return SEPOL_OK;
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad userprefix declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad userprefix declaration");
979814
 	cil_destroy_userprefix(userprefix);
979814
 	return rc;
979814
 }
979814
@@ -1566,8 +1544,7 @@ int cil_gen_selinuxuser(struct cil_db *db, struct cil_tree_node *parse_current,
979814
 
979814
 	return SEPOL_OK;
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad selinuxuser declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad selinuxuser declaration");
979814
 	cil_destroy_selinuxuser(selinuxuser);
979814
 	return rc;
979814
 }
979814
@@ -1614,8 +1591,7 @@ int cil_gen_selinuxuserdefault(struct cil_db *db, struct cil_tree_node *parse_cu
979814
 
979814
 	return SEPOL_OK;
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad selinuxuserdefault declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad selinuxuserdefault declaration");
979814
 	cil_destroy_selinuxuser(selinuxuser);
979814
 	return rc;
979814
 }
979814
@@ -1666,8 +1642,7 @@ int cil_gen_role(struct cil_db *db, struct cil_tree_node *parse_current, struct
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad role declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad role declaration");
979814
 	cil_destroy_role(role);
979814
 	cil_clear_node(ast_node);
979814
 	return rc;
979814
@@ -1717,8 +1692,7 @@ int cil_gen_roletype(struct cil_db *db, struct cil_tree_node *parse_current, str
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad roletype declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad roletype declaration");
979814
 	cil_destroy_roletype(roletype);
979814
 	return rc;
979814
 }
979814
@@ -1764,8 +1738,7 @@ int cil_gen_userrole(struct cil_db *db, struct cil_tree_node *parse_current, str
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad userrole declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad userrole declaration");
979814
 	cil_destroy_userrole(userrole);
979814
 	return rc;
979814
 }
979814
@@ -1815,8 +1788,7 @@ int cil_gen_roletransition(struct cil_tree_node *parse_current, struct cil_tree_
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad roletransition rule at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad roletransition rule");
979814
 	cil_destroy_roletransition(roletrans);
979814
 	return rc;
979814
 }
979814
@@ -1862,8 +1834,7 @@ int cil_gen_roleallow(struct cil_db *db, struct cil_tree_node *parse_current, st
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad roleallow rule at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad roleallow rule");
979814
 	cil_destroy_roleallow(roleallow);
979814
 	return rc;
979814
 }
979814
@@ -1914,8 +1885,7 @@ int cil_gen_roleattribute(struct cil_db *db, struct cil_tree_node *parse_current
979814
 
979814
 	return SEPOL_OK;
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad roleattribute declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad roleattribute declaration");
979814
 	cil_destroy_roleattribute(attr);
979814
 	cil_clear_node(ast_node);
979814
 	return rc;
979814
@@ -1982,8 +1952,7 @@ int cil_gen_roleattributeset(struct cil_db *db, struct cil_tree_node *parse_curr
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad roleattributeset declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad roleattributeset declaration");
979814
 	cil_destroy_roleattributeset(attrset);
979814
 
979814
 	return rc;
979814
@@ -2042,8 +2011,7 @@ int cil_gen_avrule(struct cil_tree_node *parse_current, struct cil_tree_node *as
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad allow rule at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad allow rule");
979814
 	cil_destroy_avrule(rule);
979814
 	return rc;
979814
 }
979814
@@ -2099,8 +2067,7 @@ int cil_fill_permissionx(struct cil_tree_node *parse_current, struct cil_permiss
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad permissionx content at line %d of %s\n",
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad permissionx content");
979814
 	return rc;
979814
 }
979814
 
979814
@@ -2143,8 +2110,7 @@ int cil_gen_permissionx(struct cil_db *db, struct cil_tree_node *parse_current,
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad permissionx statement at line %d of %s\n",
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad permissionx statement");
979814
 	cil_destroy_permissionx(permx);
979814
 	cil_clear_node(ast_node);
979814
 	return rc;
979814
@@ -2210,8 +2176,7 @@ int cil_gen_avrulex(struct cil_tree_node *parse_current, struct cil_tree_node *a
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad allowx rule at line %d of %s\n",
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad allowx rule");
979814
 	cil_destroy_avrule(rule);
979814
 	return rc;
979814
 }
979814
@@ -2253,8 +2218,7 @@ int cil_gen_type_rule(struct cil_tree_node *parse_current, struct cil_tree_node
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad type rule at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad type rule");
979814
 	cil_destroy_type_rule(rule);
979814
 	return rc;
979814
 }
979814
@@ -2306,8 +2270,7 @@ int cil_gen_type(struct cil_db *db, struct cil_tree_node *parse_current, struct
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad type declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad type declaration");
979814
 	cil_destroy_type(type);
979814
 	cil_clear_node(ast_node);
979814
 	return rc;
979814
@@ -2361,8 +2324,7 @@ int cil_gen_typeattribute(struct cil_db *db, struct cil_tree_node *parse_current
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad typeattribute declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad typeattribute declaration");
979814
 	cil_destroy_typeattribute(attr);
979814
 	cil_clear_node(ast_node);
979814
 	return rc;
979814
@@ -2439,11 +2401,9 @@ int cil_gen_bool(struct cil_db *db, struct cil_tree_node *parse_current, struct
979814
 
979814
 exit:
979814
 	if (tunableif) {
979814
-		cil_log(CIL_ERR, "Bad tunable (treated as a boolean due to preserve-tunables) declaration at line %d of %s\n",
979814
-			parse_current->line, parse_current->path);
979814
+		cil_tree_log(parse_current, CIL_ERR, "Bad tunable (treated as a boolean due to preserve-tunables) declaration");
979814
 	} else {
979814
-		cil_log(CIL_ERR, "Bad boolean declaration at line %d of %s\n",
979814
-			parse_current->line, parse_current->path);
979814
+		cil_tree_log(parse_current, CIL_ERR, "Bad boolean declaration");
979814
 	}
979814
 	cil_destroy_bool(boolean);
979814
 	cil_clear_node(ast_node);
979814
@@ -2504,8 +2464,7 @@ int cil_gen_tunable(struct cil_db *db, struct cil_tree_node *parse_current, stru
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad tunable declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad tunable declaration");
979814
 	cil_destroy_tunable(tunable);
979814
 	cil_clear_node(ast_node);
979814
 	return rc;
979814
@@ -2880,11 +2839,9 @@ int cil_gen_boolif(struct cil_db *db, struct cil_tree_node *parse_current, struc
979814
 
979814
 exit:
979814
 	if (tunableif) {
979814
-		cil_log(CIL_ERR, "Bad tunableif (treated as a booleanif due to preserve-tunables) declaration at line %d of %s\n",
979814
-				parse_current->line, parse_current->path);
979814
+		cil_tree_log(parse_current, CIL_ERR, "Bad tunableif (treated as a booleanif due to preserve-tunables) declaration");
979814
 	} else {
979814
-		cil_log(CIL_ERR, "Bad booleanif declaration at line %d of %s\n",
979814
-				parse_current->line, parse_current->path);
979814
+		cil_tree_log(parse_current, CIL_ERR, "Bad booleanif declaration");
979814
 	}
979814
 	cil_destroy_boolif(bif);
979814
 	return rc;
979814
@@ -2964,8 +2921,7 @@ int cil_gen_tunif(struct cil_db *db, struct cil_tree_node *parse_current, struct
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad tunableif declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad tunableif declaration");
979814
 	cil_destroy_tunif(tif);
979814
 	return rc;
979814
 }
979814
@@ -3018,8 +2974,8 @@ int cil_gen_condblock(struct cil_db *db, struct cil_tree_node *parse_current, st
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad %s condition declaration at line %d of %s\n",
979814
-		(char*)parse_current->data, parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad %s condition declaration",
979814
+		(char*)parse_current->data);
979814
 	cil_destroy_condblock(cb);
979814
 	return rc;
979814
 }
979814
@@ -3079,8 +3035,7 @@ int cil_gen_alias(struct cil_db *db, struct cil_tree_node *parse_current, struct
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad %s declaration at line %d of %s\n",
979814
-		(char*)parse_current->data, parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad %s declaration", (char*)parse_current->data);
979814
 	cil_destroy_alias(alias);
979814
 	cil_clear_node(ast_node);
979814
 	return rc;
979814
@@ -3137,8 +3092,7 @@ int cil_gen_aliasactual(struct cil_db *db, struct cil_tree_node *parse_current,
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad %s association at line %d of %s\n", 
979814
-			cil_node_to_string(parse_current),parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad %s association", cil_node_to_string(parse_current));
979814
 	cil_clear_node(ast_node);
979814
 	return rc;
979814
 }
979814
@@ -3187,8 +3141,7 @@ int cil_gen_typeattributeset(struct cil_db *db, struct cil_tree_node *parse_curr
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad typeattributeset statement at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad typeattributeset statement");
979814
 	cil_destroy_typeattributeset(attrset);
979814
 	return rc;
979814
 }
979814
@@ -3235,8 +3188,7 @@ int cil_gen_typepermissive(struct cil_db *db, struct cil_tree_node *parse_curren
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad typepermissive declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad typepermissive declaration");
979814
 	cil_destroy_typepermissive(typeperm);
979814
 	return rc;
979814
 }
979814
@@ -3319,8 +3271,7 @@ int cil_gen_typetransition(struct cil_db *db, struct cil_tree_node *parse_curren
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad typetransition declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad typetransition declaration");
979814
 	return rc;
979814
 }
979814
 
979814
@@ -3391,8 +3342,7 @@ int cil_gen_rangetransition(struct cil_db *db, struct cil_tree_node *parse_curre
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad rangetransition declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad rangetransition declaration");
979814
 	cil_destroy_rangetransition(rangetrans);
979814
 	return rc;
979814
 }
979814
@@ -3443,8 +3393,7 @@ int cil_gen_sensitivity(struct cil_db *db, struct cil_tree_node *parse_current,
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad sensitivity declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad sensitivity declaration");
979814
 	cil_destroy_sensitivity(sens);
979814
 	cil_clear_node(ast_node);
979814
 	return rc;
979814
@@ -3496,8 +3445,7 @@ int cil_gen_category(struct cil_db *db, struct cil_tree_node *parse_current, str
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad category declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad category declaration");
979814
 	cil_destroy_category(cat);
979814
 	cil_clear_node(ast_node);
979814
 	return rc;
979814
@@ -3552,8 +3500,7 @@ int cil_gen_catset(struct cil_db *db, struct cil_tree_node *parse_current, struc
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad categoryset declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad categoryset declaration");
979814
 	cil_destroy_catset(catset);
979814
 	cil_clear_node(ast_node);
979814
 	return rc;
979814
@@ -3614,8 +3561,7 @@ int cil_gen_catorder(struct cil_db *db, struct cil_tree_node *parse_current, str
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad categoryorder declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad categoryorder declaration");
979814
 	cil_destroy_catorder(catorder);
979814
 	return rc;
979814
 }
979814
@@ -3675,8 +3621,7 @@ int cil_gen_sensitivityorder(struct cil_db *db, struct cil_tree_node *parse_curr
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad sensitivityorder declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad sensitivityorder declaration");
979814
 	cil_destroy_sensitivityorder(sensorder);
979814
 	return rc;
979814
 }
979814
@@ -3730,8 +3675,7 @@ int cil_gen_senscat(struct cil_db *db, struct cil_tree_node *parse_current, stru
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad sensitivitycategory declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad sensitivitycategory declaration");
979814
 	cil_destroy_senscat(senscat);
979814
 	return rc;
979814
 }
979814
@@ -3786,8 +3730,7 @@ int cil_gen_level(struct cil_db *db, struct cil_tree_node *parse_current, struct
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad level declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad level declaration");
979814
 	cil_destroy_level(level);
979814
 	cil_clear_node(ast_node);
979814
 	return rc;
979814
@@ -3893,8 +3836,7 @@ int cil_gen_levelrange(struct cil_db *db, struct cil_tree_node *parse_current, s
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad levelrange declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad levelrange declaration");
979814
 	cil_destroy_levelrange(lvlrange);
979814
 	cil_clear_node(ast_node);
979814
 	return rc;
979814
@@ -3958,8 +3900,7 @@ int cil_gen_constrain(struct cil_db *db, struct cil_tree_node *parse_current, st
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad constrain declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad constrain declaration");
979814
 	cil_destroy_constrain(cons);
979814
 	return rc;
979814
 }
979814
@@ -4013,8 +3954,7 @@ int cil_gen_validatetrans(struct cil_db *db, struct cil_tree_node *parse_current
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad validatetrans declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad validatetrans declaration");
979814
 	cil_destroy_validatetrans(validtrans);
979814
 	return rc;
979814
 
979814
@@ -4118,8 +4058,7 @@ int cil_gen_context(struct cil_db *db, struct cil_tree_node *parse_current, stru
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad context declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad context declaration");
979814
 	cil_destroy_context(context);
979814
 	cil_clear_node(ast_node);
979814
 	return SEPOL_ERR;
979814
@@ -4211,8 +4150,7 @@ int cil_gen_filecon(struct cil_db *db, struct cil_tree_node *parse_current, stru
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad filecon declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad filecon declaration");
979814
 	cil_destroy_filecon(filecon);
979814
 	return rc;
979814
 }
979814
@@ -4261,6 +4199,8 @@ int cil_gen_portcon(struct cil_db *db, struct cil_tree_node *parse_current, stru
979814
 		portcon->proto = CIL_PROTOCOL_UDP;
979814
 	} else if (proto == CIL_KEY_TCP) {
979814
 		portcon->proto = CIL_PROTOCOL_TCP;
979814
+	} else if (proto == CIL_KEY_DCCP) {
979814
+		portcon->proto = CIL_PROTOCOL_DCCP;
979814
 	} else {
979814
 		cil_log(CIL_ERR, "Invalid protocol\n");
979814
 		rc = SEPOL_ERR;
979814
@@ -4311,8 +4251,7 @@ int cil_gen_portcon(struct cil_db *db, struct cil_tree_node *parse_current, stru
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad portcon declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad portcon declaration");
979814
 	cil_destroy_portcon(portcon);
979814
 	return rc;
979814
 }
979814
@@ -4393,8 +4332,7 @@ int cil_gen_nodecon(struct cil_db *db, struct cil_tree_node *parse_current, stru
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad nodecon declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad nodecon declaration");
979814
 	cil_destroy_nodecon(nodecon);
979814
 	return rc;
979814
 }
979814
@@ -4464,8 +4402,7 @@ int cil_gen_genfscon(struct cil_db *db, struct cil_tree_node *parse_current, str
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad genfscon declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad genfscon declaration");
979814
 	cil_destroy_genfscon(genfscon);
979814
 	return SEPOL_ERR;
979814
 }
979814
@@ -4538,8 +4475,7 @@ int cil_gen_netifcon(struct cil_db *db, struct cil_tree_node *parse_current, str
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad netifcon declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad netifcon declaration");
979814
 	cil_destroy_netifcon(netifcon);
979814
 	return SEPOL_ERR;
979814
 }
979814
@@ -4606,8 +4542,7 @@ int cil_gen_pirqcon(struct cil_db *db, struct cil_tree_node *parse_current, stru
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad pirqcon declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad pirqcon declaration");
979814
 	cil_destroy_pirqcon(pirqcon);
979814
 	return rc;
979814
 }
979814
@@ -4692,8 +4627,7 @@ int cil_gen_iomemcon(struct cil_db *db, struct cil_tree_node *parse_current, str
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad iomemcon declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad iomemcon declaration");
979814
 	cil_destroy_iomemcon(iomemcon);
979814
 	return rc;
979814
 }
979814
@@ -4778,8 +4712,7 @@ int cil_gen_ioportcon(struct cil_db *db, struct cil_tree_node *parse_current, st
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad ioportcon declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad ioportcon declaration");
979814
 	cil_destroy_ioportcon(ioportcon);
979814
 	return rc;
979814
 }
979814
@@ -4842,8 +4775,7 @@ int cil_gen_pcidevicecon(struct cil_db *db, struct cil_tree_node *parse_current,
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad pcidevicecon declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad pcidevicecon declaration");
979814
 	cil_destroy_pcidevicecon(pcidevicecon);
979814
 	return rc;
979814
 }
979814
@@ -4903,8 +4835,7 @@ int cil_gen_devicetreecon(struct cil_db *db, struct cil_tree_node *parse_current
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad devicetreecon declaration at line %d of %s\n",
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad devicetreecon declaration");
979814
 	cil_destroy_devicetreecon(devicetreecon);
979814
 	return rc;
979814
 }
979814
@@ -4979,8 +4910,7 @@ int cil_gen_fsuse(struct cil_db *db, struct cil_tree_node *parse_current, struct
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad fsuse declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad fsuse declaration");
979814
 	cil_destroy_fsuse(fsuse);
979814
 	return SEPOL_ERR;
979814
 }
979814
@@ -5137,8 +5067,7 @@ int cil_gen_macro(struct cil_db *db, struct cil_tree_node *parse_current, struct
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad macro declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad macro declaration");
979814
 	cil_destroy_macro(macro);
979814
 	cil_clear_node(ast_node);
979814
 	return SEPOL_ERR;
979814
@@ -5196,8 +5125,7 @@ int cil_gen_call(struct cil_db *db, struct cil_tree_node *parse_current, struct
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad macro call at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad macro call");
979814
 	cil_destroy_call(call);
979814
 	return rc;
979814
 }
979814
@@ -5299,8 +5227,7 @@ int cil_gen_optional(struct cil_db *db, struct cil_tree_node *parse_current, str
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad optional at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad optional");
979814
 	cil_destroy_optional(optional);
979814
 	cil_clear_node(ast_node);
979814
 	return rc;
979814
@@ -5348,8 +5275,7 @@ int cil_gen_policycap(struct cil_db *db, struct cil_tree_node *parse_current, st
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad policycap statement at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad policycap statement");
979814
 	cil_destroy_policycap(polcap);
979814
 	cil_clear_node(ast_node);
979814
 	return rc;
979814
@@ -5404,8 +5330,7 @@ int cil_gen_ipaddr(struct cil_db *db, struct cil_tree_node *parse_current, struc
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad ipaddr statement at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad ipaddr statement");
979814
 	cil_destroy_ipaddr(ipaddr);
979814
 	cil_clear_node(ast_node);
979814
 	return rc;
979814
@@ -5609,8 +5534,7 @@ int cil_gen_bounds(struct cil_db *db, struct cil_tree_node *parse_current, struc
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad bounds declaration at line %d of %s\n", 
979814
-		parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad bounds declaration");
979814
 	cil_destroy_bounds(bounds);
979814
 	return rc;
979814
 }
979814
@@ -5671,8 +5595,7 @@ int cil_gen_default(struct cil_tree_node *parse_current, struct cil_tree_node *a
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad %s declaration at line %d of %s\n", 
979814
-			cil_node_to_string(parse_current), parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad %s declaration", cil_node_to_string(parse_current));
979814
 	cil_destroy_default(def);
979814
 	return rc;
979814
 }
979814
@@ -5758,8 +5681,7 @@ int cil_gen_defaultrange(struct cil_tree_node *parse_current, struct cil_tree_no
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad defaultrange declaration at line %d of %s\n", 
979814
-			parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad defaultrange declaration");
979814
 	cil_destroy_defaultrange(def);
979814
 	return rc;
979814
 }
979814
@@ -5819,8 +5741,7 @@ int cil_gen_handleunknown(struct cil_tree_node *parse_current, struct cil_tree_n
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad handleunknown at line %d of %s\n",
979814
-			parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad handleunknown");
979814
 	cil_destroy_handleunknown(unknown);
979814
 	return rc;
979814
 }
979814
@@ -5868,8 +5789,7 @@ int cil_gen_mls(struct cil_tree_node *parse_current, struct cil_tree_node *ast_n
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad mls at line %d of %s\n",
979814
-			parse_current->line, parse_current->path);
979814
+	cil_tree_log(parse_current, CIL_ERR, "Bad mls");
979814
 	cil_destroy_mls(mls);
979814
 	return rc;
979814
 }
979814
@@ -5879,6 +5799,27 @@ void cil_destroy_mls(struct cil_mls *mls)
979814
 	free(mls);
979814
 }
979814
 
979814
+int cil_gen_src_info(struct cil_tree_node *parse_current, struct cil_tree_node *ast_node)
979814
+{
979814
+	/* No need to check syntax, because this is auto generated */
979814
+	struct cil_src_info *info = NULL;
979814
+
979814
+	cil_src_info_init(&info;;
979814
+
979814
+	info->is_cil = (parse_current->next->data == CIL_KEY_SRC_CIL) ? CIL_TRUE : CIL_FALSE;
979814
+	info->path = parse_current->next->next->data;
979814
+
979814
+	ast_node->data = info;
979814
+	ast_node->flavor = CIL_SRC_INFO;
979814
+
979814
+	return SEPOL_OK;
979814
+}
979814
+
979814
+void cil_destroy_src_info(struct cil_src_info *info)
979814
+{
979814
+	free(info);
979814
+}
979814
+
979814
 int __cil_build_ast_node_helper(struct cil_tree_node *parse_current, uint32_t *finished, void *extra_args)
979814
 {
979814
 	struct cil_args_build *args = NULL;
979814
@@ -5913,7 +5854,7 @@ int __cil_build_ast_node_helper(struct cil_tree_node *parse_current, uint32_t *f
979814
 		if (parse_current->parent->parent == NULL) {
979814
 			rc = SEPOL_OK;
979814
 		} else {
979814
-			cil_log(CIL_ERR, "Keyword expected after open parenthesis in line %d of %s\n", parse_current->line, parse_current->path);
979814
+			cil_tree_log(parse_current, CIL_ERR, "Keyword expected after open parenthesis");
979814
 		}
979814
 		goto exit;
979814
 	}
979814
@@ -5926,7 +5867,7 @@ int __cil_build_ast_node_helper(struct cil_tree_node *parse_current, uint32_t *f
979814
 			parse_current->data == CIL_KEY_BLOCKINHERIT ||
979814
 			parse_current->data == CIL_KEY_BLOCKABSTRACT) {
979814
 			rc = SEPOL_ERR;
979814
-			cil_log(CIL_ERR, "%s is not allowed in macros (%s:%d)\n", (char *)parse_current->data, parse_current->path, parse_current->line);
979814
+			cil_tree_log(parse_current, CIL_ERR, "%s is not allowed in macros", (char *)parse_current->data);
979814
 			goto exit;
979814
 		}
979814
 	}
979814
@@ -5942,8 +5883,7 @@ int __cil_build_ast_node_helper(struct cil_tree_node *parse_current, uint32_t *f
979814
 			parse_current->data != CIL_KEY_TYPECHANGE &&
979814
 			parse_current->data != CIL_KEY_CALL) {
979814
 			rc = SEPOL_ERR;
979814
-			cil_log(CIL_ERR, "Found %s at line %d of %s\n",
979814
-				(char*)parse_current->data, parse_current->line, parse_current->path);
979814
+			cil_tree_log(parse_current, CIL_ERR, "Found %s", (char*)parse_current->data);
979814
 			if (((struct cil_booleanif*)boolif->data)->preserved_tunable) {
979814
 				cil_log(CIL_ERR, "%s cannot be defined within tunableif statement (treated as a booleanif due to preserve-tunables)\n",
979814
 						(char*)parse_current->data);
979814
@@ -5958,8 +5898,7 @@ int __cil_build_ast_node_helper(struct cil_tree_node *parse_current, uint32_t *f
979814
 	if (tunif != NULL) {
979814
 		if (parse_current->data == CIL_KEY_TUNABLE) {
979814
 			rc = SEPOL_ERR;
979814
-			cil_log(CIL_ERR, "Found tunable at line %d of %s\n",
979814
-				parse_current->line, parse_current->path);
979814
+			cil_tree_log(parse_current, CIL_ERR, "Found tunable");
979814
 			cil_log(CIL_ERR, "Tunables cannot be defined within tunableif statement\n");
979814
 			goto exit;
979814
 		}
979814
@@ -5968,8 +5907,7 @@ int __cil_build_ast_node_helper(struct cil_tree_node *parse_current, uint32_t *f
979814
 	if (in != NULL) {
979814
 		if (parse_current->data == CIL_KEY_IN) {
979814
 			rc = SEPOL_ERR;
979814
-			cil_log(CIL_ERR, "Found in-statement at line %d of %s\n",
979814
-				parse_current->line, parse_current->path);
979814
+			cil_tree_log(parse_current, CIL_ERR, "Found in-statement");
979814
 			cil_log(CIL_ERR, "in-statements cannot be defined within in-statements\n");
979814
 			goto exit;
979814
 		}
979814
@@ -5979,7 +5917,7 @@ int __cil_build_ast_node_helper(struct cil_tree_node *parse_current, uint32_t *f
979814
 
979814
 	ast_node->parent = ast_current;
979814
 	ast_node->line = parse_current->line;
979814
-	ast_node->path = parse_current->path;
979814
+	ast_node->hll_line = parse_current->hll_line;
979814
 
979814
 	if (parse_current->data == CIL_KEY_BLOCK) {
979814
 		rc = cil_gen_block(db, parse_current, ast_node, 0);
979814
@@ -6242,8 +6180,10 @@ int __cil_build_ast_node_helper(struct cil_tree_node *parse_current, uint32_t *f
979814
 	} else if (parse_current->data == CIL_KEY_MLS) {
979814
 		rc = cil_gen_mls(parse_current, ast_node);
979814
 		*finished = CIL_TREE_SKIP_NEXT;
979814
+	} else if (parse_current->data == CIL_KEY_SRC_INFO) {
979814
+		rc = cil_gen_src_info(parse_current, ast_node);
979814
 	} else {
979814
-		cil_log(CIL_ERR, "Error: Unknown keyword %s\n", (char*)parse_current->data);
979814
+		cil_log(CIL_ERR, "Error: Unknown keyword %s\n", (char *)parse_current->data);
979814
 		rc = SEPOL_ERR;
979814
 	}
979814
 
979814
@@ -6264,7 +6204,7 @@ int __cil_build_ast_node_helper(struct cil_tree_node *parse_current, uint32_t *f
979814
 			if (ast_current->flavor == CIL_IN) {
979814
 				args->in = ast_current;
979814
 			}
979814
-		
979814
+
979814
 			ast_current->cl_head = ast_node;
979814
 		} else {
979814
 			ast_current->cl_tail->next = ast_node;
979814
diff --git libsepol-2.5/cil/src/cil_build_ast.h libsepol-2.5/cil/src/cil_build_ast.h
979814
index f428394..825029e 100644
979814
--- libsepol-2.5/cil/src/cil_build_ast.h
979814
+++ libsepol-2.5/cil/src/cil_build_ast.h
979814
@@ -215,6 +215,8 @@ int cil_gen_mls(struct cil_tree_node *parse_current, struct cil_tree_node *ast_n
979814
 void cil_destroy_mls(struct cil_mls *mls);
979814
 int cil_gen_defaultrange(struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
979814
 void cil_destroy_defaultrange(struct cil_defaultrange *def);
979814
+int cil_gen_src_info(struct cil_tree_node *parse_current, struct cil_tree_node *ast_node);
979814
+void cil_destroy_src_info(struct cil_src_info *info);
979814
 
979814
 int cil_fill_cats(struct cil_tree_node *curr, struct cil_cats **cats);
979814
 void cil_destroy_cats(struct cil_cats *cats);
979814
diff --git libsepol-2.5/cil/src/cil_copy_ast.c libsepol-2.5/cil/src/cil_copy_ast.c
979814
index 0be1dda..5debd0d 100644
979814
--- libsepol-2.5/cil/src/cil_copy_ast.c
979814
+++ libsepol-2.5/cil/src/cil_copy_ast.c
979814
@@ -1666,6 +1666,21 @@ int cil_copy_bounds(__attribute__((unused)) struct cil_db *db, void *data, void
979814
 	return SEPOL_OK;
979814
 }
979814
 
979814
+int cil_copy_src_info(__attribute__((unused)) struct cil_db *db, void *data, void **copy, __attribute__((unused)) symtab_t *symtab)
979814
+{
979814
+	struct cil_src_info *orig = data;
979814
+	struct cil_src_info *new = NULL;
979814
+
979814
+	cil_src_info_init(&new;;
979814
+
979814
+	new->is_cil = orig->is_cil;
979814
+	new->path = orig->path;
979814
+
979814
+	*copy = new;
979814
+
979814
+	return SEPOL_OK;
979814
+}
979814
+
979814
 int __cil_copy_node_helper(struct cil_tree_node *orig, __attribute__((unused)) uint32_t *finished, void *extra_args)
979814
 {
979814
 	int rc = SEPOL_ERR;
979814
@@ -1942,6 +1957,9 @@ int __cil_copy_node_helper(struct cil_tree_node *orig, __attribute__((unused)) u
979814
 	case CIL_MLS:
979814
 		copy_func = &cil_copy_mls;
979814
 		break;
979814
+	case CIL_SRC_INFO:
979814
+		copy_func = &cil_copy_src_info;
979814
+		break;
979814
 	default:
979814
 		goto exit;
979814
 	}
979814
@@ -1964,7 +1982,7 @@ int __cil_copy_node_helper(struct cil_tree_node *orig, __attribute__((unused)) u
979814
 
979814
 		new->parent = parent;
979814
 		new->line = orig->line;
979814
-		new->path = orig->path;
979814
+		new->hll_line = orig->hll_line;
979814
 		new->flavor = orig->flavor;
979814
 		new->data = data;
979814
 
979814
@@ -1985,8 +2003,8 @@ int __cil_copy_node_helper(struct cil_tree_node *orig, __attribute__((unused)) u
979814
 						param = item->data;
979814
 						if (param->flavor == new->flavor) {
979814
 							if (param->str == ((struct cil_symtab_datum*)new->data)->name) {
979814
-								cil_log(CIL_ERR, "%s %s shadows a macro parameter (%s line:%d)\n", cil_node_to_string(new), ((struct cil_symtab_datum*)orig->data)->name, orig->path, orig->line);
979814
-								cil_log(CIL_ERR, "Note: macro declaration (%s line:%d)\n", namespace->path, namespace->line);
979814
+								cil_tree_log(orig, CIL_ERR, "%s %s shadows a macro parameter", cil_node_to_string(new), ((struct cil_symtab_datum*)orig->data)->name);
979814
+								cil_tree_log(namespace, CIL_ERR, "Note: macro declaration");
979814
 								rc = SEPOL_ERR;
979814
 								goto exit;
979814
 							}
979814
diff --git libsepol-2.5/cil/src/cil_find.c libsepol-2.5/cil/src/cil_find.c
979814
index 75de886..4134242 100644
979814
--- libsepol-2.5/cil/src/cil_find.c
979814
+++ libsepol-2.5/cil/src/cil_find.c
979814
@@ -69,7 +69,11 @@ static int cil_type_match_any(struct cil_symtab_datum *d1, struct cil_symtab_dat
979814
 		/* Both are attributes */
979814
 		struct cil_typeattribute *a1 = (struct cil_typeattribute *)d1;
979814
 		struct cil_typeattribute *a2 = (struct cil_typeattribute *)d2;
979814
-		return ebitmap_match_any(a1->types, a2->types);
979814
+		if (d1 == d2) {
979814
+			return CIL_TRUE;
979814
+		} else if (ebitmap_match_any(a1->types, a2->types)) {
979814
+			return CIL_TRUE;
979814
+		}
979814
 	}
979814
 	return CIL_FALSE;
979814
 }
979814
@@ -379,7 +383,7 @@ int cil_find_matching_avrule_in_ast(struct cil_tree_node *current, enum cil_flav
979814
 
979814
 	rc = cil_tree_walk(current, __cil_find_matching_avrule_in_ast, NULL, NULL, &args);
979814
 	if (rc) {
979814
-		cil_log(CIL_ERR, "An error occured while searching for avrule in AST\n");
979814
+		cil_log(CIL_ERR, "An error occurred while searching for avrule in AST\n");
979814
 	}
979814
 
979814
 	return rc;
979814
diff --git libsepol-2.5/cil/src/cil_flavor.h libsepol-2.5/cil/src/cil_flavor.h
979814
index 9fb5083..cd08b97 100644
979814
--- libsepol-2.5/cil/src/cil_flavor.h
979814
+++ libsepol-2.5/cil/src/cil_flavor.h
979814
@@ -111,6 +111,7 @@ enum cil_flavor {
979814
 	CIL_DEFAULTRANGE,
979814
 	CIL_HANDLEUNKNOWN,
979814
 	CIL_MLS,
979814
+	CIL_SRC_INFO,
979814
 
979814
 /*
979814
  *          boolean  constraint  set  catset
979814
diff --git libsepol-2.5/cil/src/cil_fqn.c libsepol-2.5/cil/src/cil_fqn.c
979814
index 865bd7d..dad1347 100644
979814
--- libsepol-2.5/cil/src/cil_fqn.c
979814
+++ libsepol-2.5/cil/src/cil_fqn.c
979814
@@ -121,7 +121,7 @@ static int __cil_fqn_qualify_blocks(__attribute__((unused)) hashtab_key_t k, has
979814
 
979814
 exit:
979814
 	if (rc != SEPOL_OK) {
979814
-		cil_log(CIL_ERR,"Problem qualifying names in block at line %d of %s\n", child_args.node->line, child_args.node->path);
979814
+		cil_tree_log(child_args.node, CIL_ERR,"Problem qualifying names in block");
979814
 	}
979814
 
979814
 	return rc;
979814
diff --git libsepol-2.5/cil/src/cil_internal.h libsepol-2.5/cil/src/cil_internal.h
979814
index a0a5480..5875dc9 100644
979814
--- libsepol-2.5/cil/src/cil_internal.h
979814
+++ libsepol-2.5/cil/src/cil_internal.h
979814
@@ -101,6 +101,7 @@ char *CIL_KEY_OBJECT_R;
979814
 char *CIL_KEY_STAR;
979814
 char *CIL_KEY_TCP;
979814
 char *CIL_KEY_UDP;
979814
+char *CIL_KEY_DCCP;
979814
 char *CIL_KEY_AUDITALLOW;
979814
 char *CIL_KEY_TUNABLEIF;
979814
 char *CIL_KEY_ALLOW;
979814
@@ -225,6 +226,9 @@ char *CIL_KEY_NEVERALLOWX;
979814
 char *CIL_KEY_PERMISSIONX;
979814
 char *CIL_KEY_IOCTL;
979814
 char *CIL_KEY_UNORDERED;
979814
+char *CIL_KEY_SRC_INFO;
979814
+char *CIL_KEY_SRC_CIL;
979814
+char *CIL_KEY_SRC_HLL;
979814
 
979814
 /*
979814
 	Symbol Table Array Indices
979814
@@ -713,7 +717,8 @@ struct cil_filecon {
979814
 
979814
 enum cil_protocol {
979814
 	CIL_PROTOCOL_UDP = 1,
979814
-	CIL_PROTOCOL_TCP	
979814
+	CIL_PROTOCOL_TCP,
979814
+	CIL_PROTOCOL_DCCP
979814
 };
979814
 
979814
 struct cil_portcon {
979814
@@ -915,6 +920,11 @@ struct cil_mls {
979814
 	int value;
979814
 };
979814
 
979814
+struct cil_src_info {
979814
+	int is_cil;
979814
+	char *path;
979814
+};
979814
+
979814
 void cil_db_init(struct cil_db **db);
979814
 void cil_db_destroy(struct cil_db **db);
979814
 
979814
@@ -1017,6 +1027,7 @@ void cil_default_init(struct cil_default **def);
979814
 void cil_defaultrange_init(struct cil_defaultrange **def);
979814
 void cil_handleunknown_init(struct cil_handleunknown **unk);
979814
 void cil_mls_init(struct cil_mls **mls);
979814
+void cil_src_info_init(struct cil_src_info **info);
979814
 void cil_userattribute_init(struct cil_userattribute **attribute);
979814
 void cil_userattributeset_init(struct cil_userattributeset **attrset);
979814
 
979814
diff --git libsepol-2.5/cil/src/cil_lexer.h libsepol-2.5/cil/src/cil_lexer.h
979814
index 1537d5e..ab555d8 100644
979814
--- libsepol-2.5/cil/src/cil_lexer.h
979814
+++ libsepol-2.5/cil/src/cil_lexer.h
979814
@@ -37,8 +37,10 @@
979814
 #define SYMBOL 3
979814
 #define QSTRING 4
979814
 #define COMMENT 5
979814
-#define END_OF_FILE 6
979814
-#define UNKNOWN 7
979814
+#define HLL_LINEMARK 6
979814
+#define NEWLINE 7
979814
+#define END_OF_FILE 8
979814
+#define UNKNOWN 9
979814
 
979814
 struct token {
979814
 	uint32_t type;
979814
diff --git libsepol-2.5/cil/src/cil_lexer.l libsepol-2.5/cil/src/cil_lexer.l
979814
index 8e4c207..e28c33e 100644
979814
--- libsepol-2.5/cil/src/cil_lexer.l
979814
+++ libsepol-2.5/cil/src/cil_lexer.l
979814
@@ -50,15 +50,17 @@ symbol		({digit}|{alpha}|{spec_char})+
979814
 white		[ \t]
979814
 newline		[\n\r]
979814
 qstring		\"[^"\n]*\"
979814
-comment		;[^\n]*
979814
+hll_lm          ^;;\*
979814
+comment		;
979814
 
979814
 %%
979814
-{newline}	line++; 
979814
+{newline}	line++; return NEWLINE;
979814
+{hll_lm}	value=yytext; return HLL_LINEMARK;
979814
 {comment}	value=yytext; return COMMENT;
979814
 "("		value=yytext; return OPAREN;
979814
-")"		value=yytext; return CPAREN;	
979814
+")"		value=yytext; return CPAREN;
979814
 {symbol}	value=yytext; return SYMBOL;
979814
-{white}		//cil_log(CIL_INFO, "white, ");
979814
+{white}		;
979814
 {qstring}	value=yytext; return QSTRING;
979814
 <<EOF>>		return END_OF_FILE;
979814
 .		value=yytext; return UNKNOWN;
979814
@@ -73,7 +75,7 @@ int cil_lexer_setup(char *buffer, uint32_t size)
979814
 	}
979814
 
979814
 	line = 1;
979814
-	
979814
+
979814
 	return SEPOL_OK;
979814
 }
979814
 
979814
@@ -87,7 +89,6 @@ int cil_lexer_next(struct token *tok)
979814
 	tok->type = yylex();
979814
 	tok->value = value;
979814
 	tok->line = line;
979814
-	
979814
+
979814
 	return SEPOL_OK;
979814
 }
979814
-
979814
diff --git libsepol-2.5/cil/src/cil_parser.c libsepol-2.5/cil/src/cil_parser.c
979814
index d0e108c..101520c 100644
979814
--- libsepol-2.5/cil/src/cil_parser.c
979814
+++ libsepol-2.5/cil/src/cil_parser.c
979814
@@ -36,9 +36,165 @@
979814
 #include "cil_internal.h"
979814
 #include "cil_log.h"
979814
 #include "cil_mem.h"
979814
-#include "cil_tree.h" 
979814
+#include "cil_tree.h"
979814
 #include "cil_lexer.h"
979814
 #include "cil_strpool.h"
979814
+#include "cil_stack.h"
979814
+
979814
+char *CIL_KEY_HLL_LMS;
979814
+char *CIL_KEY_HLL_LMX;
979814
+char *CIL_KEY_HLL_LME;
979814
+
979814
+struct hll_info {
979814
+	int hll_lineno;
979814
+	int hll_expand;
979814
+};
979814
+
979814
+static void push_hll_info(struct cil_stack *stack, int hll_lineno, int hll_expand)
979814
+{
979814
+	struct hll_info *new = cil_malloc(sizeof(*new));
979814
+
979814
+	new->hll_lineno = hll_lineno;
979814
+	new->hll_expand = hll_expand;
979814
+
979814
+	cil_stack_push(stack, CIL_NONE, new);
979814
+}
979814
+
979814
+static void pop_hll_info(struct cil_stack *stack, int *hll_lineno, int *hll_expand)
979814
+{
979814
+	struct cil_stack_item *curr = cil_stack_pop(stack);
979814
+	struct cil_stack_item *prev = cil_stack_peek(stack);
979814
+	struct hll_info *old;
979814
+
979814
+	free(curr->data);
979814
+
979814
+	if (!prev) {
979814
+		*hll_lineno = -1;
979814
+		*hll_expand = -1;
979814
+	} else {
979814
+		old = prev->data;
979814
+		*hll_lineno = old->hll_lineno;
979814
+		*hll_expand = old->hll_expand;
979814
+	}
979814
+}
979814
+
979814
+static void create_node(struct cil_tree_node **node, struct cil_tree_node *current, int line, int hll_line, void *value)
979814
+{
979814
+	cil_tree_node_init(node);
979814
+	(*node)->parent = current;
979814
+	(*node)->flavor = CIL_NODE;
979814
+	(*node)->line = line;
979814
+	(*node)->hll_line = hll_line;
979814
+	(*node)->data = value;
979814
+}
979814
+
979814
+static void insert_node(struct cil_tree_node *node, struct cil_tree_node *current)
979814
+{
979814
+	if (current->cl_head == NULL) {
979814
+		current->cl_head = node;
979814
+	} else {
979814
+		current->cl_tail->next = node;
979814
+	}
979814
+	current->cl_tail = node;
979814
+}
979814
+
979814
+static int add_hll_linemark(struct cil_tree_node **current, int *hll_lineno, int *hll_expand, struct cil_stack *stack, char *path)
979814
+{
979814
+	char *hll_type;
979814
+	struct cil_tree_node *node;
979814
+	struct token tok;
979814
+	char *hll_file;
979814
+	char *end = NULL;
979814
+
979814
+	cil_lexer_next(&tok;;
979814
+	hll_type = cil_strpool_add(tok.value);
979814
+	if (hll_type == CIL_KEY_HLL_LME) {
979814
+		if (cil_stack_is_empty(stack)) {
979814
+			cil_log(CIL_ERR, "Line mark end without start\n");
979814
+			goto exit;
979814
+		}
979814
+		pop_hll_info(stack, hll_lineno, hll_expand);
979814
+		*current = (*current)->parent;
979814
+	} else {
979814
+		create_node(&node, *current, tok.line, *hll_lineno, NULL);
979814
+		insert_node(node, *current);
979814
+		*current = node;
979814
+
979814
+		create_node(&node, *current, tok.line, *hll_lineno, CIL_KEY_SRC_INFO);
979814
+		insert_node(node, *current);
979814
+
979814
+		create_node(&node, *current, tok.line, *hll_lineno, CIL_KEY_SRC_HLL);
979814
+		insert_node(node, *current);
979814
+
979814
+		if (hll_type == CIL_KEY_HLL_LMS) {
979814
+			*hll_expand = 0;
979814
+		} else if (hll_type == CIL_KEY_HLL_LMX) {
979814
+			*hll_expand = 1;
979814
+		} else {
979814
+			cil_log(CIL_ERR, "Invalid line mark syntax\n");
979814
+			goto exit;
979814
+		}
979814
+
979814
+		cil_lexer_next(&tok;;
979814
+		if (tok.type != SYMBOL) {
979814
+			cil_log(CIL_ERR, "Invalid line mark syntax\n");
979814
+			goto exit;
979814
+		}
979814
+		*hll_lineno = strtol(tok.value, &end, 10);
979814
+		if (errno == ERANGE || *end != '\0') {
979814
+			cil_log(CIL_ERR, "Problem parsing line number for line mark\n");
979814
+			goto exit;
979814
+		}
979814
+
979814
+		push_hll_info(stack, *hll_lineno, *hll_expand);
979814
+
979814
+		cil_lexer_next(&tok;;
979814
+		if (tok.type != SYMBOL && tok.type != QSTRING) {
979814
+			cil_log(CIL_ERR, "Invalid line mark syntax\n");
979814
+			goto exit;
979814
+		}
979814
+
979814
+		if (tok.type == QSTRING) {
979814
+			tok.value[strlen(tok.value) - 1] = '\0';
979814
+			tok.value = tok.value+1;
979814
+		}
979814
+
979814
+		hll_file = cil_strpool_add(tok.value);
979814
+
979814
+		create_node(&node, *current, tok.line, *hll_lineno, hll_file);
979814
+		insert_node(node, *current);
979814
+	}
979814
+
979814
+	cil_lexer_next(&tok;;
979814
+	if (tok.type != NEWLINE) {
979814
+		cil_log(CIL_ERR, "Invalid line mark syntax\n");
979814
+		goto exit;
979814
+	}
979814
+
979814
+	return SEPOL_OK;
979814
+
979814
+exit:
979814
+	cil_log(CIL_ERR, "Problem with high-level line mark at line %d of %s\n", tok.line, path);
979814
+	return SEPOL_ERR;
979814
+}
979814
+
979814
+static void add_cil_path(struct cil_tree_node **current, char *path)
979814
+{
979814
+	struct cil_tree_node *node;
979814
+
979814
+	create_node(&node, *current, 0, 0, NULL);
979814
+	insert_node(node, *current);
979814
+	*current = node;
979814
+
979814
+	create_node(&node, *current, 0, 0, CIL_KEY_SRC_INFO);
979814
+	insert_node(node, *current);
979814
+
979814
+	create_node(&node, *current, 0, 0, CIL_KEY_SRC_CIL);
979814
+	insert_node(node, *current);
979814
+
979814
+	create_node(&node, *current, 0, 0, path);
979814
+	insert_node(node, *current);
979814
+}
979814
 
979814
 int cil_parser(char *_path, char *buffer, uint32_t size, struct cil_tree **parse_tree)
979814
 {
979814
@@ -47,89 +203,112 @@ int cil_parser(char *_path, char *buffer, uint32_t size, struct cil_tree **parse
979814
 
979814
 	struct cil_tree *tree = NULL;
979814
 	struct cil_tree_node *node = NULL;
979814
-	struct cil_tree_node *item = NULL;
979814
 	struct cil_tree_node *current = NULL;
979814
 	char *path = cil_strpool_add(_path);
979814
-
979814
+	struct cil_stack *stack;
979814
+	int hll_lineno = -1;
979814
+	int hll_expand = -1;
979814
 	struct token tok;
979814
+	int rc = SEPOL_OK;
979814
+
979814
+	CIL_KEY_HLL_LMS = cil_strpool_add("lms");
979814
+	CIL_KEY_HLL_LMX = cil_strpool_add("lmx");
979814
+	CIL_KEY_HLL_LME = cil_strpool_add("lme");
979814
+
979814
+	cil_stack_init(&stack);
979814
 
979814
 	cil_lexer_setup(buffer, size);
979814
 
979814
 	tree = *parse_tree;
979814
-	current = tree->root;	
979814
+	current = tree->root;
979814
+
979814
+	add_cil_path(&current, path);
979814
 
979814
 	do {
979814
 		cil_lexer_next(&tok;;
979814
 		switch (tok.type) {
979814
+		case HLL_LINEMARK:
979814
+			rc = add_hll_linemark(&current, &hll_lineno, &hll_expand, stack, path);
979814
+			if (rc != SEPOL_OK) {
979814
+				goto exit;
979814
+			}
979814
+			break;
979814
 		case OPAREN:
979814
 			paren_count++;
979814
-			cil_tree_node_init(&node);
979814
-			node->parent = current;
979814
-			node->flavor = CIL_NODE;
979814
-			node->line = tok.line;
979814
-			node->path = path;
979814
-			if (current->cl_head == NULL) {
979814
-				current->cl_head = node;
979814
-			} else {
979814
-				current->cl_tail->next = node;
979814
-			}
979814
-			current->cl_tail = node;
979814
+
979814
+			create_node(&node, current, tok.line, hll_lineno, NULL);
979814
+			insert_node(node, current);
979814
 			current = node;
979814
 			break;
979814
 		case CPAREN:
979814
 			paren_count--;
979814
 			if (paren_count < 0) {
979814
 				cil_log(CIL_ERR, "Close parenthesis without matching open at line %d of %s\n", tok.line, path);
979814
-				return SEPOL_ERR;
979814
+				goto exit;
979814
 			}
979814
 			current = current->parent;
979814
 			break;
979814
-		case SYMBOL:
979814
 		case QSTRING:
979814
+			tok.value[strlen(tok.value) - 1] = '\0';
979814
+			tok.value = tok.value+1;
979814
+		case SYMBOL:
979814
 			if (paren_count == 0) {
979814
 				cil_log(CIL_ERR, "Symbol not inside parenthesis at line %d of %s\n", tok.line, path);
979814
-				return SEPOL_ERR;
979814
+				goto exit;
979814
 			}
979814
-			cil_tree_node_init(&item);
979814
-			item->parent = current;
979814
-			if (tok.type == QSTRING) {
979814
-				tok.value[strlen(tok.value) - 1] = '\0';
979814
-				item->data = cil_strpool_add(tok.value + 1);
979814
-			} else {
979814
-				item->data = cil_strpool_add(tok.value);
979814
-			}
979814
-			item->flavor = CIL_NODE;
979814
-			item->line = tok.line;
979814
-			item->path = path;
979814
-			if (current->cl_head == NULL) {
979814
-				current->cl_head = item;
979814
-			} else {
979814
-				current->cl_tail->next = item;
979814
+
979814
+			create_node(&node, current, tok.line, hll_lineno, cil_strpool_add(tok.value));
979814
+			insert_node(node, current);
979814
+			break;
979814
+		case NEWLINE :
979814
+			if (!hll_expand) {
979814
+				hll_lineno++;
979814
 			}
979814
-			current->cl_tail = item;
979814
 			break;
979814
+		case COMMENT:
979814
+			while (tok.type != NEWLINE && tok.type != END_OF_FILE) {
979814
+				cil_lexer_next(&tok;;
979814
+			}
979814
+			if (!hll_expand) {
979814
+				hll_lineno++;
979814
+			}
979814
+			if (tok.type != END_OF_FILE) {
979814
+				break;
979814
+			}
979814
+			// Fall through if EOF
979814
 		case END_OF_FILE:
979814
 			if (paren_count > 0) {
979814
 				cil_log(CIL_ERR, "Open parenthesis without matching close at line %d of %s\n", tok.line, path);
979814
-				return SEPOL_ERR;
979814
+				goto exit;
979814
+			}
979814
+			if (!cil_stack_is_empty(stack)) {
979814
+				cil_log(CIL_ERR, "High-level language line marker start without close at line %d of %s\n", tok.line, path);
979814
+				goto exit;
979814
 			}
979814
-			break;
979814
-		case COMMENT:
979814
-			// ignore
979814
 			break;
979814
 		case UNKNOWN:
979814
 			cil_log(CIL_ERR, "Invalid token '%s' at line %d of %s\n", tok.value, tok.line, path);
979814
-			return SEPOL_ERR;
979814
+			goto exit;
979814
 		default:
979814
 			cil_log(CIL_ERR, "Unknown token type '%d' at line %d of %s\n", tok.type, tok.line, path);
979814
-			return SEPOL_ERR;
979814
+			goto exit;
979814
 		}
979814
 	}
979814
 	while (tok.type != END_OF_FILE);
979814
 
979814
 	cil_lexer_destroy();
979814
 
979814
+	cil_stack_destroy(&stack);
979814
+
979814
 	*parse_tree = tree;
979814
 
979814
 	return SEPOL_OK;
979814
+
979814
+exit:
979814
+	while (!cil_stack_is_empty(stack)) {
979814
+		pop_hll_info(stack, &hll_lineno, &hll_expand);
979814
+	}
979814
+	cil_stack_destroy(&stack);
979814
+
979814
+	return SEPOL_ERR;
979814
 }
979814
diff --git libsepol-2.5/cil/src/cil_policy.c libsepol-2.5/cil/src/cil_policy.c
979814
index 2c9b158..382129b 100644
979814
--- libsepol-2.5/cil/src/cil_policy.c
979814
+++ libsepol-2.5/cil/src/cil_policy.c
979814
@@ -123,6 +123,8 @@ int cil_portcon_to_policy(FILE **file_arr, struct cil_sort *sort)
979814
 			fprintf(file_arr[NETIFCONS], "udp ");
979814
 		} else if (portcon->proto == CIL_PROTOCOL_TCP) {
979814
 			fprintf(file_arr[NETIFCONS], "tcp ");
979814
+		} else if (portcon->proto == CIL_PROTOCOL_DCCP) {
979814
+			fprintf(file_arr[NETIFCONS], "dccp ");
979814
 		}
979814
 		fprintf(file_arr[NETIFCONS], "%d ", portcon->port_low);
979814
 		fprintf(file_arr[NETIFCONS], "%d ", portcon->port_high);
979814
diff --git libsepol-2.5/cil/src/cil_reset_ast.c libsepol-2.5/cil/src/cil_reset_ast.c
979814
index 06146ca..de00679 100644
979814
--- libsepol-2.5/cil/src/cil_reset_ast.c
979814
+++ libsepol-2.5/cil/src/cil_reset_ast.c
979814
@@ -23,7 +23,7 @@ static void cil_reset_class(struct cil_class *class)
979814
 {
979814
 	if (class->common != NULL) {
979814
 		struct cil_class *common = class->common;
979814
-		cil_symtab_map(&common->perms, __class_reset_perm_values, &common->num_perms);
979814
+		cil_symtab_map(&class->perms, __class_reset_perm_values, &common->num_perms);
979814
 		/* during a re-resolve, we need to reset the common, so a classcommon
979814
 		 * statement isn't seen as a duplicate */
979814
 		class->num_perms -= common->num_perms;
979814
diff --git libsepol-2.5/cil/src/cil_resolve_ast.c libsepol-2.5/cil/src/cil_resolve_ast.c
979814
index 1489680..8348d57 100644
979814
--- libsepol-2.5/cil/src/cil_resolve_ast.c
979814
+++ libsepol-2.5/cil/src/cil_resolve_ast.c
979814
@@ -131,10 +131,10 @@ static int __cil_resolve_perms(symtab_t *class_symtab, symtab_t *common_symtab,
979814
 				}
979814
 			}
979814
 			if (rc != SEPOL_OK) {
979814
-				cil_log(CIL_ERR, "Failed to resolve permission %s\n", (char*)curr->data);
979814
-				goto exit;
979814
+				cil_log(CIL_WARN, "Failed to resolve permission %s\n", (char*)curr->data);
979814
+			} else {
979814
+				cil_list_append(*perm_datums, CIL_DATUM, perm_datum);
979814
 			}
979814
-			cil_list_append(*perm_datums, CIL_DATUM, perm_datum);
979814
 		} else {
979814
 			cil_list_append(*perm_datums, curr->flavor, curr->data);
979814
 		}
979814
@@ -497,7 +497,7 @@ int cil_resolve_alias_to_actual(struct cil_tree_node *current, enum cil_flavor f
979814
 	int limit = 2;
979814
 
979814
 	if (alias->actual == NULL) {
979814
-		cil_log(CIL_ERR, "Alias declared but not used at line %d of %s\n",current->line, current->path);
979814
+		cil_tree_log(current, CIL_ERR, "Alias declared but not used");
979814
 		return SEPOL_ERR;
979814
 	}
979814
 
979814
@@ -1380,7 +1380,7 @@ struct cil_list *__cil_ordered_lists_merge_all(struct cil_list **ordered_lists,
979814
 			cil_list_for_each(curr, *ordered_lists) {
979814
 				struct cil_ordered_list *ordered_list = curr->data;
979814
 				if (ordered_list->merged == CIL_FALSE) {
979814
-					cil_log(CIL_ERR, "Unable to merge ordered list at line %d of %s\n",ordered_list->node->line, ordered_list->node->path);
979814
+					cil_tree_log(ordered_list->node, CIL_ERR, "Unable to merge ordered list");
979814
 				}
979814
 			}
979814
 			goto exit;
979814
@@ -2252,12 +2252,10 @@ void cil_print_recursive_blockinherit(struct cil_tree_node *bi_node, struct cil_
979814
 
979814
 	cil_list_for_each(item, trace) {
979814
 		curr = item->data;
979814
-		cil_log(CIL_ERR, "  %s:%d: ", curr->path, curr->line);
979814
-
979814
 		if (curr->flavor == CIL_BLOCK) {
979814
-			cil_log(CIL_ERR, "block %s\n", DATUM(curr->data)->name);
979814
+			cil_tree_log(curr, CIL_ERR, "block %s", DATUM(curr->data)->name);
979814
 		} else {
979814
-			cil_log(CIL_ERR, "blockinherit %s\n", ((struct cil_blockinherit *)curr->data)->block_str);
979814
+			cil_tree_log(curr, CIL_ERR, "blockinherit %s", ((struct cil_blockinherit *)curr->data)->block_str);
979814
 		}
979814
 	}
979814
 
979814
@@ -2442,7 +2440,7 @@ int cil_resolve_in_list(void *extra_args)
979814
 		}
979814
 
979814
 		if (unresolved > 0 && resolved == 0) {
979814
-			cil_log(CIL_ERR, "Failed to resolve in-statement on line %d of %s\n", last_failed_node->line, last_failed_node->path);
979814
+			cil_tree_log(last_failed_node, CIL_ERR, "Failed to resolve in-statement");
979814
 			rc = SEPOL_ERR;
979814
 			goto exit;
979814
 		}
979814
@@ -2485,7 +2483,7 @@ int cil_resolve_bounds(struct cil_tree_node *current, void *extra_args, enum cil
979814
 
979814
 		if (user->bounds != NULL) {
979814
 			struct cil_tree_node *node = user->bounds->datum.nodes->head->data;
979814
-			cil_log(CIL_ERR, "User %s already bound by parent at line %u of %s\n", bounds->child_str, node->line, node->path);
979814
+			cil_tree_log(node, CIL_ERR, "User %s already bound by parent", bounds->child_str);
979814
 			rc = SEPOL_ERR;
979814
 			goto exit;
979814
 		}
979814
@@ -2498,7 +2496,7 @@ int cil_resolve_bounds(struct cil_tree_node *current, void *extra_args, enum cil
979814
 
979814
 		if (role->bounds != NULL) {
979814
 			struct cil_tree_node *node = role->bounds->datum.nodes->head->data;
979814
-			cil_log(CIL_ERR, "Role %s already bound by parent at line %u of %s\n", bounds->child_str, node->line, node->path);
979814
+			cil_tree_log(node, CIL_ERR, "Role %s already bound by parent", bounds->child_str);
979814
 			rc = SEPOL_ERR;
979814
 			goto exit;
979814
 		}
979814
@@ -2512,8 +2510,8 @@ int cil_resolve_bounds(struct cil_tree_node *current, void *extra_args, enum cil
979814
 
979814
 		if (type->bounds != NULL) {
979814
 			node = ((struct cil_symtab_datum *)type->bounds)->nodes->head->data;
979814
-			cil_log(CIL_ERR, "Type %s already bound by parent at line %u of %s\n", bounds->child_str, node->line, node->path);
979814
-			cil_log(CIL_ERR, "Now being bound to parent %s at line %u of %s\n", bounds->parent_str, current->line, current->path);
979814
+			cil_tree_log(node, CIL_ERR, "Type %s already bound by parent", bounds->child_str);
979814
+			cil_tree_log(current, CIL_ERR, "Now being bound to parent %s", bounds->parent_str);
979814
 			rc = SEPOL_ERR;
979814
 			goto exit;
979814
 		}
979814
@@ -2542,7 +2540,7 @@ int cil_resolve_bounds(struct cil_tree_node *current, void *extra_args, enum cil
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Bad bounds statement at line %u of %s\n", current->line, current->path);
979814
+	cil_tree_log(current, CIL_ERR, "Bad bounds statement");
979814
 	return rc;
979814
 }
979814
 
979814
@@ -2617,12 +2615,10 @@ void cil_print_recursive_call(struct cil_tree_node *call_node, struct cil_tree_n
979814
 
979814
 	cil_list_for_each(item, trace) {
979814
 		curr = item->data;
979814
-		cil_log(CIL_ERR, "  %s:%d: ", curr->path, curr->line);
979814
-
979814
 		if (curr->flavor == CIL_MACRO) {
979814
-			cil_log(CIL_ERR, "macro %s\n", DATUM(curr->data)->name);
979814
+			cil_tree_log(curr, CIL_ERR, "macro %s", DATUM(curr->data)->name);
979814
 		} else {
979814
-			cil_log(CIL_ERR, "call %s\n", ((struct cil_call *)curr->data)->macro_str);
979814
+			cil_tree_log(curr, CIL_ERR, "call %s", ((struct cil_call *)curr->data)->macro_str);
979814
 		}
979814
 	}
979814
 
979814
@@ -2700,7 +2696,7 @@ int cil_resolve_call1(struct cil_tree_node *current, void *extra_args)
979814
 		struct cil_tree_node *pc = NULL;
979814
 
979814
 		if (new_call->args_tree == NULL) {
979814
-			cil_log(CIL_ERR, "Missing arguments (%s, line: %d)\n", current->path, current->line);
979814
+			cil_tree_log(current, CIL_ERR, "Missing arguments");
979814
 			rc = SEPOL_ERR;
979814
 			goto exit;
979814
 		}
979814
@@ -2713,7 +2709,7 @@ int cil_resolve_call1(struct cil_tree_node *current, void *extra_args)
979814
 			enum cil_flavor flavor = ((struct cil_param*)item->data)->flavor;
979814
 
979814
 			if (pc == NULL) {
979814
-				cil_log(CIL_ERR, "Missing arguments (%s, line: %d)\n", current->path, current->line);
979814
+				cil_tree_log(current, CIL_ERR, "Missing arguments");
979814
 				rc = SEPOL_ERR;
979814
 				goto exit;
979814
 			}
979814
@@ -2890,12 +2886,12 @@ int cil_resolve_call1(struct cil_tree_node *current, void *extra_args)
979814
 		}
979814
 
979814
 		if (pc != NULL) {
979814
-			cil_log(CIL_ERR, "Unexpected arguments (%s, line: %d)\n", current->path, current->line);
979814
+			cil_tree_log(current, CIL_ERR, "Unexpected arguments");
979814
 			rc = SEPOL_ERR;
979814
 			goto exit;
979814
 		}
979814
 	} else if (new_call->args_tree != NULL) {
979814
-		cil_log(CIL_ERR, "Unexpected arguments (%s, line: %d)\n", current->path, current->line);
979814
+		cil_tree_log(current, CIL_ERR, "Unexpected arguments");
979814
 		rc = SEPOL_ERR;
979814
 		goto exit;
979814
 	}
979814
@@ -3593,7 +3589,7 @@ int __cil_resolve_ast_node_helper(struct cil_tree_node *node, uint32_t *finished
979814
 	if (optstack != NULL) {
979814
 		if (node->flavor == CIL_TUNABLE || node->flavor == CIL_MACRO) {
979814
 			/* tuanbles and macros are not allowed in optionals*/
979814
-			cil_log(CIL_ERR, "%s statement is not allowed in optionals (%s:%d)\n", cil_node_to_string(node), node->path, node->line);
979814
+			cil_tree_log(node, CIL_ERR, "%s statement is not allowed in optionals", cil_node_to_string(node));
979814
 			rc = SEPOL_ERR;
979814
 			goto exit;
979814
 		}
979814
@@ -3601,7 +3597,7 @@ int __cil_resolve_ast_node_helper(struct cil_tree_node *node, uint32_t *finished
979814
 
979814
 	if (blockstack != NULL) {
979814
 		if (node->flavor == CIL_CAT || node->flavor == CIL_SENS) {
979814
-			cil_log(CIL_ERR, "%s statement is not allowed in blocks (%s:%d)\n", cil_node_to_string(node), node->path, node->line);
979814
+			cil_tree_log(node, CIL_ERR, "%s statement is not allowed in blocks", cil_node_to_string(node));
979814
 			rc = SEPOL_ERR;
979814
 			goto exit;
979814
 		}
979814
@@ -3612,7 +3608,7 @@ int __cil_resolve_ast_node_helper(struct cil_tree_node *node, uint32_t *finished
979814
 			node->flavor == CIL_BLOCK ||
979814
 			node->flavor == CIL_BLOCKABSTRACT ||
979814
 			node->flavor == CIL_MACRO) {
979814
-			cil_log(CIL_ERR, "%s statement is not allowed in macros (%s:%d)\n", cil_node_to_string(node), node->path, node->line);
979814
+			cil_tree_log(node, CIL_ERR, "%s statement is not allowed in macros", cil_node_to_string(node));
979814
 			rc = SEPOL_ERR;
979814
 			goto exit;
979814
 		}
979814
@@ -3626,9 +3622,9 @@ int __cil_resolve_ast_node_helper(struct cil_tree_node *node, uint32_t *finished
979814
 			node->flavor == CIL_TUNABLEIF ||
979814
 			node->flavor == CIL_NAMETYPETRANSITION)) {
979814
 			if (((struct cil_booleanif*)boolif->data)->preserved_tunable) {
979814
-				cil_log(CIL_ERR, "%s statement is not allowed in booleanifs (tunableif treated as a booleanif) (%s:%d)\n", cil_node_to_string(node), node->path, node->line);
979814
+				cil_tree_log(node, CIL_ERR, "%s statement is not allowed in booleanifs (tunableif treated as a booleanif)", cil_node_to_string(node));
979814
 			} else {
979814
-				cil_log(CIL_ERR, "%s statement is not allowed in booleanifs (%s:%d)\n", cil_node_to_string(node), node->path, node->line);
979814
+				cil_tree_log(node, CIL_ERR, "%s statement is not allowed in booleanifs", cil_node_to_string(node));
979814
 			}
979814
 			rc = SEPOL_ERR;
979814
 			goto exit;
979814
@@ -3658,14 +3654,13 @@ int __cil_resolve_ast_node_helper(struct cil_tree_node *node, uint32_t *finished
979814
 
979814
 			struct cil_optional *opt = (struct cil_optional *)optstack->data;
979814
 			struct cil_tree_node *opt_node = opt->datum.nodes->head->data;
979814
-			cil_log(lvl, "Disabling optional '%s' at line %d of %s: ", opt->datum.name, opt_node->line, opt_node->path);
979814
+			cil_tree_log(opt_node, lvl, "Disabling optional '%s'", opt->datum.name);
979814
 			/* disable an optional if something failed to resolve */
979814
 			opt->enabled = CIL_FALSE;
979814
 			rc = SEPOL_OK;
979814
 		}
979814
 
979814
-		cil_log(lvl, "Failed to resolve '%s' in %s statement at line %d of %s\n",
979814
-		        args->last_resolved_name, cil_node_to_string(node), node->line, node->path);
979814
+		cil_tree_log(node, lvl, "Failed to resolve %s statement", cil_node_to_string(node));
979814
 		goto exit;
979814
 	}
979814
 
979814
diff --git libsepol-2.5/cil/src/cil_tree.c libsepol-2.5/cil/src/cil_tree.c
979814
index 1c23efc..9ff9d4b 100644
979814
--- libsepol-2.5/cil/src/cil_tree.c
979814
+++ libsepol-2.5/cil/src/cil_tree.c
979814
@@ -59,6 +59,92 @@ __attribute__((noreturn)) __attribute__((format (printf, 1, 2))) void cil_tree_e
979814
 	exit(1);
979814
 }
979814
 
979814
+struct cil_tree_node *cil_tree_get_next_path(struct cil_tree_node *node, char **path, int* is_cil)
979814
+{
979814
+	if (!node) {
979814
+		return NULL;
979814
+	}
979814
+
979814
+	node = node->parent;
979814
+
979814
+	while (node) {
979814
+		if (node->flavor == CIL_NODE && node->data == NULL) {
979814
+			if (node->cl_head->data == CIL_KEY_SRC_INFO) {
979814
+				/* Parse Tree */
979814
+				*path = node->cl_head->next->next->data;
979814
+				*is_cil = (node->cl_head->next->data == CIL_KEY_SRC_CIL);
979814
+				return node;
979814
+			}
979814
+			node = node->parent;
979814
+		} else if (node->flavor == CIL_SRC_INFO) {
979814
+				/* AST */
979814
+				struct cil_src_info *info = node->data;
979814
+				*path = info->path;
979814
+				*is_cil = info->is_cil;
979814
+				return node;
979814
+		} else {
979814
+			if (node->flavor == CIL_CALL) {
979814
+				struct cil_call *call = node->data;
979814
+				node = NODE(call->macro);
979814
+			} else if (node->flavor == CIL_BLOCKINHERIT) {
979814
+				struct cil_blockinherit *inherit = node->data;
979814
+				node = NODE(inherit->block);
979814
+			} else {
979814
+				node = node->parent;
979814
+			}
979814
+		}
979814
+	}
979814
+
979814
+	return NULL;
979814
+}
979814
+
979814
+char *cil_tree_get_cil_path(struct cil_tree_node *node)
979814
+{
979814
+	char *path = NULL;
979814
+	int is_cil;
979814
+
979814
+	while (node) {
979814
+		node = cil_tree_get_next_path(node, &path, &is_cil);
979814
+		if (node && is_cil) {
979814
+			return path;
979814
+		}
979814
+	}
979814
+
979814
+	return NULL;
979814
+}
979814
+
979814
+__attribute__((format (printf, 3, 4))) void cil_tree_log(struct cil_tree_node *node, enum cil_log_level lvl, const char* msg, ...)
979814
+{
979814
+	va_list ap;
979814
+
979814
+	va_start(ap, msg);
979814
+	cil_vlog(lvl, msg, ap);
979814
+	va_end(ap);
979814
+
979814
+	if (node) {
979814
+		char *path = NULL;
979814
+		int is_cil;
979814
+		unsigned hll_line = node->hll_line;
979814
+
979814
+		path = cil_tree_get_cil_path(node);
979814
+
979814
+		if (path != NULL) {
979814
+			cil_log(lvl, " at %s:%d", path, node->line);
979814
+		}
979814
+
979814
+		while (node) {
979814
+			node = cil_tree_get_next_path(node, &path, &is_cil);
979814
+			if (node && !is_cil) {
979814
+				cil_log(lvl," from %s:%d", path, hll_line);
979814
+				path = NULL;
979814
+				hll_line = node->hll_line;
979814
+			}
979814
+		}
979814
+	}
979814
+
979814
+	cil_log(lvl,"\n");
979814
+}
979814
+
979814
 int cil_tree_init(struct cil_tree **tree)
979814
 {
979814
 	struct cil_tree *new_tree = cil_malloc(sizeof(*new_tree));
979814
@@ -128,8 +214,8 @@ void cil_tree_node_init(struct cil_tree_node **node)
979814
 	new_node->data = NULL;
979814
 	new_node->next = NULL;
979814
 	new_node->flavor = CIL_ROOT;
979814
-	new_node->line = 0;	
979814
-	new_node->path = NULL;
979814
+	new_node->line = 0;
979814
+	new_node->hll_line = 0;
979814
 
979814
 	*node = new_node;
979814
 }
979814
@@ -185,7 +271,7 @@ int cil_tree_walk_core(struct cil_tree_node *node,
979814
 		if (process_node != NULL) {
979814
 			rc = (*process_node)(node, &finished, extra_args);
979814
 			if (rc != SEPOL_OK) {
979814
-				cil_log(CIL_INFO, "Problem at line %d of %s\n", node->line, node->path);
979814
+				cil_tree_log(node, CIL_INFO, "Problem");
979814
 				return rc;
979814
 			}
979814
 		}
979814
@@ -222,7 +308,7 @@ int cil_tree_walk(struct cil_tree_node *node,
979814
 	if (first_child != NULL) {
979814
 		rc = (*first_child)(node->cl_head, extra_args);
979814
 		if (rc != SEPOL_OK) {
979814
-			cil_log(CIL_INFO, "Problem at line %d of %s\n", node->line, node->path);
979814
+			cil_tree_log(node, CIL_INFO, "Problem");
979814
 			return rc;
979814
 		}
979814
 	}
979814
@@ -235,7 +321,7 @@ int cil_tree_walk(struct cil_tree_node *node,
979814
 	if (last_child != NULL) {
979814
 		rc = (*last_child)(node->cl_tail, extra_args);
979814
 		if (rc != SEPOL_OK) {
979814
-			cil_log(CIL_INFO, "Problem at line %d of %s\n",node->line, node->path);
979814
+			cil_tree_log(node, CIL_INFO, "Problem");
979814
 			return rc;
979814
 		}
979814
 	}
979814
@@ -1319,6 +1405,8 @@ void cil_tree_print_node(struct cil_tree_node *node)
979814
 				cil_log(CIL_INFO, " udp");
979814
 			} else if (portcon->proto == CIL_PROTOCOL_TCP) {
979814
 				cil_log(CIL_INFO, " tcp");
979814
+			} else if (portcon->proto == CIL_PROTOCOL_DCCP) {
979814
+				cil_log(CIL_INFO, " dccp");
979814
 			}
979814
 			cil_log(CIL_INFO, " (%d %d)", portcon->port_low, portcon->port_high);
979814
 
979814
diff --git libsepol-2.5/cil/src/cil_tree.h libsepol-2.5/cil/src/cil_tree.h
979814
index 9bb602f..aeded56 100644
979814
--- libsepol-2.5/cil/src/cil_tree.h
979814
+++ libsepol-2.5/cil/src/cil_tree.h
979814
@@ -46,10 +46,14 @@ struct cil_tree_node {
979814
 	struct cil_tree_node *next;		//Each element in the list points to the next element
979814
 	enum cil_flavor flavor;
979814
 	uint32_t line;
979814
-	char *path;
979814
+	uint32_t hll_line;
979814
 	void *data;
979814
 };
979814
 
979814
+struct cil_tree_node *cil_tree_get_next_path(struct cil_tree_node *node, char **path, int* is_cil);
979814
+char *cil_tree_get_cil_path(struct cil_tree_node *node);
979814
+__attribute__((format (printf, 3, 4))) void cil_tree_log(struct cil_tree_node *node, enum cil_log_level lvl, const char* msg, ...);
979814
+
979814
 int cil_tree_init(struct cil_tree **tree);
979814
 void cil_tree_destroy(struct cil_tree **tree);
979814
 void cil_tree_subtree_destroy(struct cil_tree_node *node);
979814
diff --git libsepol-2.5/cil/src/cil_verify.c libsepol-2.5/cil/src/cil_verify.c
979814
index 36ec45a..038f77a 100644
979814
--- libsepol-2.5/cil/src/cil_verify.c
979814
+++ libsepol-2.5/cil/src/cil_verify.c
979814
@@ -377,25 +377,25 @@ int __cil_verify_ordered_node_helper(struct cil_tree_node *node, __attribute__((
979814
 		if (node->flavor == CIL_SID) {
979814
 			struct cil_sid *sid = node->data;
979814
 			if (sid->ordered == CIL_FALSE) {
979814
-				cil_log(CIL_ERR, "SID %s not in sidorder statement at line %d of %s\n", sid->datum.name, node->line, node->path);
979814
+				cil_tree_log(node, CIL_ERR, "SID %s not in sidorder statement", sid->datum.name);
979814
 				return SEPOL_ERR;
979814
 			}
979814
 		} else if (node->flavor == CIL_CLASS) {
979814
 			struct cil_class *class = node->data;
979814
 			if (class->ordered == CIL_FALSE) {
979814
-				cil_log(CIL_ERR, "Class %s not in classorder statement at line %d of %s\n", class->datum.name, node->line, node->path);
979814
+				cil_tree_log(node, CIL_ERR, "Class %s not in classorder statement", class->datum.name);
979814
 				return SEPOL_ERR;
979814
 			}
979814
 		} else if (node->flavor == CIL_CAT) {
979814
 			struct cil_cat *cat = node->data;
979814
 			if (cat->ordered == CIL_FALSE) {
979814
-				cil_log(CIL_ERR, "Category %s not in categoryorder statement at line %d of %s\n", cat->datum.name, node->line, node->path);
979814
+				cil_tree_log(node, CIL_ERR, "Category %s not in categoryorder statement", cat->datum.name);
979814
 				return SEPOL_ERR;
979814
 			}
979814
 		} else if (node->flavor == CIL_SENS) {
979814
 			struct cil_sens *sens = node->data;
979814
 			if (sens->ordered == CIL_FALSE) {
979814
-				cil_log(CIL_ERR, "Sensitivity %s not in sensitivityorder statement at line %d of %s\n", sens->datum.name, node->line, node->path);
979814
+				cil_tree_log(node, CIL_ERR, "Sensitivity %s not in sensitivityorder statement", sens->datum.name);
979814
 				return SEPOL_ERR;
979814
 			}
979814
 		}
979814
@@ -430,7 +430,7 @@ int __cil_verify_initsids(struct cil_list *sids)
979814
 		struct cil_sid *sid = i->data;
979814
 		if (sid->context == NULL) {
979814
 			struct cil_tree_node *node = sid->datum.nodes->head->data;
979814
-			cil_log(CIL_ERR, "No context assigned to SID %s declared at line %d in %s\n",sid->datum.name, node->line, node->path);
979814
+			cil_tree_log(node, CIL_ERR, "No context assigned to SID %s declared",sid->datum.name);
979814
 			rc = SEPOL_ERR;
979814
 		}
979814
 	}
979814
@@ -598,7 +598,7 @@ int __cil_verify_named_levelrange(struct cil_db *db, struct cil_tree_node *node)
979814
 
979814
 	return SEPOL_OK;
979814
 exit:
979814
-	cil_log(CIL_ERR, "Invalid named range at line %d of %s\n", node->line, node->path);
979814
+	cil_tree_log(node, CIL_ERR, "Invalid named range");
979814
 	return rc;
979814
 }
979814
 
979814
@@ -638,7 +638,7 @@ static int __cil_verify_user_pre_eval(struct cil_tree_node *node)
979814
 
979814
 	return SEPOL_OK;
979814
 exit:
979814
-	cil_log(CIL_ERR, "Invalid user at line %d of %s\n", node->line, node->path);
979814
+	cil_tree_log(node, CIL_ERR, "Invalid user");
979814
 	return rc;
979814
 }
979814
 
979814
@@ -657,7 +657,7 @@ static int __cil_verify_user_post_eval(struct cil_db *db, struct cil_tree_node *
979814
 
979814
 	return SEPOL_OK;
979814
 exit:
979814
-	cil_log(CIL_ERR, "Invalid user at line %d of %s\n", node->line, node->path);
979814
+	cil_tree_log(node, CIL_ERR, "Invalid user");
979814
 	return rc;
979814
 }
979814
 
979814
@@ -688,7 +688,7 @@ int __cil_verify_role(struct cil_tree_node *node)
979814
 
979814
 	return SEPOL_OK;
979814
 exit:
979814
-	cil_log(CIL_ERR, "Invalid role at line %d of %s\n", node->line, node->path);
979814
+	cil_tree_log(node, CIL_ERR, "Invalid role");
979814
 	return rc;
979814
 }
979814
 
979814
@@ -719,7 +719,7 @@ int __cil_verify_type(struct cil_tree_node *node)
979814
 
979814
 	return SEPOL_OK;
979814
 exit:
979814
-	cil_log(CIL_ERR, "Invalid type at line %d of %s\n", node->line, node->path);
979814
+	cil_tree_log(node, CIL_ERR, "Invalid type");
979814
 	return rc;
979814
 }
979814
 
979814
@@ -813,7 +813,7 @@ int __cil_verify_named_context(struct cil_db *db, struct cil_tree_node *node)
979814
 
979814
 	return SEPOL_OK;
979814
 exit:
979814
-	cil_log(CIL_ERR, "Invalid named context at line %d of %s\n", node->line, node->path);
979814
+	cil_tree_log(node, CIL_ERR, "Invalid named context");
979814
 	return rc;
979814
 }
979814
 
979814
@@ -852,8 +852,7 @@ int __cil_verify_rule(struct cil_tree_node *node, struct cil_complex_symtab *sym
979814
 		struct cil_complex_symtab_datum *datum = NULL;
979814
 		cil_complex_symtab_search(symtab, &ckey, &datum);
979814
 		if (datum == NULL) {
979814
-			cil_log(CIL_ERR, "Duplicate rule defined on line %d of %s\n", 
979814
-				node->line, node->path);
979814
+			cil_tree_log(node, CIL_ERR, "Duplicate rule defined");
979814
 			rc = SEPOL_ERR;
979814
 			goto exit;
979814
 		}
979814
@@ -861,7 +860,7 @@ int __cil_verify_rule(struct cil_tree_node *node, struct cil_complex_symtab *sym
979814
 
979814
 	return SEPOL_OK;
979814
 exit:
979814
-	cil_log(CIL_ERR, "Invalid rule at line %d of %s\n", node->line, node->path);
979814
+	cil_tree_log(node, CIL_ERR, "Invalid rule");
979814
 	return rc;
979814
 }
979814
 
979814
@@ -877,11 +876,9 @@ int __cil_verify_booleanif_helper(struct cil_tree_node *node, __attribute__((unu
979814
 		avrule = rule_node->data;
979814
 		if (avrule->rule_kind == CIL_AVRULE_NEVERALLOW) {
979814
 			if (bif->preserved_tunable) {
979814
-				cil_log(CIL_ERR, "Neverallow found in tunableif block (treated as a booleanif due to preserve-tunables) at line %d or %s\n",
979814
-					node->line, node->path);
979814
+				cil_tree_log(node, CIL_ERR, "Neverallow found in tunableif block (treated as a booleanif due to preserve-tunables)");
979814
 			} else {
979814
-				cil_log(CIL_ERR, "Neverallow found in booleanif block at line %d or %s\n",
979814
-					node->line, node->path);
979814
+				cil_tree_log(node, CIL_ERR, "Neverallow found in booleanif block");
979814
 			}
979814
 			rc = SEPOL_ERR;
979814
 			goto exit;
979814
@@ -942,11 +939,9 @@ int __cil_verify_booleanif_helper(struct cil_tree_node *node, __attribute__((unu
979814
 	default: {
979814
 		const char * flavor = cil_node_to_string(node);
979814
 		if (bif->preserved_tunable) {
979814
-			cil_log(CIL_ERR, "Invalid %s statement in tunableif (treated as a booleanif due to preserve-tunables) at line %d of %s\n",
979814
-					flavor, node->line, node->path);
979814
+			cil_tree_log(node, CIL_ERR, "Invalid %s statement in tunableif (treated as a booleanif due to preserve-tunables)", flavor);
979814
 		} else {
979814
-			cil_log(CIL_ERR, "Invalid %s statement in booleanif at line %d of %s\n",
979814
-					flavor, node->line, node->path);
979814
+			cil_tree_log(node, CIL_ERR, "Invalid %s statement in booleanif", flavor);
979814
 		}
979814
 		goto exit;
979814
 	}
979814
@@ -974,9 +969,9 @@ int __cil_verify_booleanif(struct cil_tree_node *node, struct cil_complex_symtab
979814
 	return SEPOL_OK;
979814
 exit:
979814
 	if (bif->preserved_tunable) {
979814
-		cil_log(CIL_ERR, "Invalid tunableif (treated as a booleanif due to preserve-tunables) at line %d of %s\n", node->line, node->path);
979814
+		cil_tree_log(node, CIL_ERR, "Invalid tunableif (treated as a booleanif due to preserve-tunables)");
979814
 	} else {
979814
-		cil_log(CIL_ERR, "Invalid booleanif at line %d of %s\n", node->line, node->path);
979814
+		cil_tree_log(node, CIL_ERR, "Invalid booleanif");
979814
 	}
979814
 	return rc;
979814
 }
979814
@@ -1007,7 +1002,7 @@ int __cil_verify_netifcon(struct cil_db *db, struct cil_tree_node *node)
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Invalid netifcon at line %d of %s\n", node->line, node->path);
979814
+	cil_tree_log(node, CIL_ERR, "Invalid netifcon");
979814
 	return rc;
979814
 }
979814
 
979814
@@ -1028,7 +1023,7 @@ int __cil_verify_genfscon(struct cil_db *db, struct cil_tree_node *node)
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Invalid genfscon at line %d of %s\n", node->line, node->path);
979814
+	cil_tree_log(node, CIL_ERR, "Invalid genfscon");
979814
 	return rc;
979814
 }
979814
 
979814
@@ -1047,8 +1042,7 @@ int __cil_verify_filecon(struct cil_db *db, struct cil_tree_node *node)
979814
 	if (ctx->datum.name == NULL) {
979814
 		rc = __cil_verify_context(db, ctx);
979814
 		if (rc != SEPOL_OK) {
979814
-			cil_log(CIL_ERR, "Invalid filecon at line %d of %s\n", 
979814
-				node->line, node->path);
979814
+			cil_tree_log(node, CIL_ERR, "Invalid filecon");
979814
 			goto exit;
979814
 		}
979814
 	}
979814
@@ -1076,7 +1070,7 @@ int __cil_verify_nodecon(struct cil_db *db, struct cil_tree_node *node)
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Invalid nodecon at line %d of %s\n", node->line, node->path);
979814
+	cil_tree_log(node, CIL_ERR, "Invalid nodecon");
979814
 	return rc;
979814
 }
979814
 
979814
@@ -1097,7 +1091,7 @@ int __cil_verify_portcon(struct cil_db *db, struct cil_tree_node *node)
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Invalid portcon at line %d of %s\n", node->line, node->path);
979814
+	cil_tree_log(node, CIL_ERR, "Invalid portcon");
979814
 	return rc;
979814
 }
979814
 
979814
@@ -1118,7 +1112,7 @@ int __cil_verify_pirqcon(struct cil_db *db, struct cil_tree_node *node)
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Invalid pirqcon at line %d of %s\n", node->line, node->path);
979814
+	cil_tree_log(node, CIL_ERR, "Invalid pirqcon");
979814
 	return rc;
979814
 }
979814
 
979814
@@ -1139,7 +1133,7 @@ int __cil_verify_iomemcon(struct cil_db *db, struct cil_tree_node *node)
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Invalid iomemcon at line %d of %s\n", node->line, node->path);
979814
+	cil_tree_log(node, CIL_ERR, "Invalid iomemcon");
979814
 	return rc;
979814
 }
979814
 
979814
@@ -1160,7 +1154,7 @@ int __cil_verify_ioportcon(struct cil_db *db, struct cil_tree_node *node)
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Invalid ioportcon at line %d of %s\n", node->line, node->path);
979814
+	cil_tree_log(node, CIL_ERR, "Invalid ioportcon");
979814
 	return rc;
979814
 }
979814
 
979814
@@ -1181,7 +1175,7 @@ int __cil_verify_pcidevicecon(struct cil_db *db, struct cil_tree_node *node)
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Invalid pcidevicecon at line %d of %s\n", node->line, node->path);
979814
+	cil_tree_log(node, CIL_ERR, "Invalid pcidevicecon");
979814
 	return rc;
979814
 }
979814
 
979814
@@ -1202,7 +1196,7 @@ int __cil_verify_devicetreecon(struct cil_db *db, struct cil_tree_node *node)
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Invalid devicetreecon at line %d of %s\n", node->line, node->path);
979814
+	cil_tree_log(node, CIL_ERR, "Invalid devicetreecon");
979814
 	return rc;
979814
 }
979814
 
979814
@@ -1223,7 +1217,7 @@ int __cil_verify_fsuse(struct cil_db *db, struct cil_tree_node *node)
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Invalid fsuse at line %d of %s\n", node->line, node->path);
979814
+	cil_tree_log(node, CIL_ERR, "Invalid fsuse");
979814
 	return rc;
979814
 }
979814
 
979814
@@ -1241,7 +1235,7 @@ int __cil_verify_permissionx(struct cil_permissionx *permx, struct cil_tree_node
979814
 			kind_str = CIL_KEY_IOCTL;
979814
 			break;
979814
 		default:
979814
-			cil_log(CIL_ERR, "Invalid permissionx kind (%d) at line %d of %s\n", permx->kind, node->line, node->path);
979814
+			cil_tree_log(node, CIL_ERR, "Invalid permissionx kind (%d)", permx->kind);
979814
 			rc = SEPOL_ERR;
979814
 			goto exit;
979814
 	}
979814
@@ -1257,7 +1251,7 @@ int __cil_verify_permissionx(struct cil_permissionx *permx, struct cil_tree_node
979814
 			}
979814
 
979814
 			if (rc == SEPOL_ENOENT) {
979814
-				cil_log(CIL_ERR, "Invalid permissionx at line %d of %s: %s is not a permission of class %s\n", node->line, node->path, kind_str, class->datum.name);
979814
+				cil_tree_log(node, CIL_ERR, "Invalid permissionx: %s is not a permission of class %s", kind_str, class->datum.name);
979814
 				rc = SEPOL_ERR;
979814
 				goto exit;
979814
 			}
979814
@@ -1312,7 +1306,7 @@ int __cil_verify_class(struct cil_tree_node *node)
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Invalid class at line %d of %s\n", node->line, node->path);
979814
+	cil_tree_log(node, CIL_ERR, "Invalid class");
979814
 	return rc;
979814
 }
979814
 
979814
@@ -1329,8 +1323,7 @@ int __cil_verify_policycap(struct cil_tree_node *node)
979814
 	return SEPOL_OK;
979814
 
979814
 exit:
979814
-	cil_log(CIL_ERR, "Invalid policycap (%s) at line %d of %s\n", 
979814
-		(const char*)polcap->datum.name, node->line, node->path);
979814
+	cil_tree_log(node, CIL_ERR, "Invalid policycap (%s)", (const char*)polcap->datum.name);
979814
 	return rc;
979814
 }
979814
 
979814
@@ -1547,14 +1540,14 @@ static int __cil_verify_classpermission(struct cil_tree_node *node)
979814
 	struct cil_classpermission *cp = node->data;
979814
 
979814
 	if (cp->classperms == NULL) {
979814
-		cil_log(CIL_ERR, "Classpermission %s does not have a classpermissionset at line %d of %s\n", cp->datum.name, node->line, node->path);
979814
+		cil_tree_log(node, CIL_ERR, "Classpermission %s does not have a classpermissionset", cp->datum.name);
979814
 		rc = SEPOL_ERR;
979814
 		goto exit;
979814
 	}
979814
 
979814
 	rc = __cil_verify_classperms(cp->classperms, &cp->datum);
979814
 	if (rc != SEPOL_OK) {
979814
-		cil_log(CIL_ERR, "Found circular class permissions involving the set %s at line %d of %s\n",cp->datum.name, node->line, node->path);
979814
+		cil_tree_log(node, CIL_ERR, "Found circular class permissions involving the set %s",cp->datum.name);
979814
 		goto exit;
979814
 	}
979814
 
979814
@@ -1577,14 +1570,14 @@ static int __verify_map_perm_classperms(__attribute__((unused)) hashtab_key_t k,
979814
 	struct cil_perm *cmp = (struct cil_perm *)d;
979814
 
979814
 	if (cmp->classperms == NULL) {
979814
-		cil_log(CIL_ERR, "Map class %s does not have a classmapping for %s at line %d of %s\n", map_args->class->datum.name, cmp->datum.name, map_args->node->line, map_args->node->path);
979814
+		cil_tree_log(map_args->node, CIL_ERR, "Map class %s does not have a classmapping for %s", map_args->class->datum.name, cmp->datum.name);
979814
 		map_args->rc = SEPOL_ERR;
979814
 		goto exit;
979814
 	}
979814
 
979814
 	rc = __cil_verify_classperms(cmp->classperms, &cmp->datum);
979814
 	if (rc != SEPOL_OK) {
979814
-		cil_log(CIL_ERR, "Found circular class permissions involving the map class %s and permission %s at line %d of %s\n", map_args->class->datum.name, cmp->datum.name, map_args->node->line, map_args->node->path);
979814
+		cil_tree_log(map_args->node, CIL_ERR, "Found circular class permissions involving the map class %s and permission %s", map_args->class->datum.name, cmp->datum.name);
979814
 		map_args->rc = SEPOL_ERR;
979814
 		goto exit;
979814
 	}
979814
diff --git libsepol-2.5/include/sepol/port_record.h libsepol-2.5/include/sepol/port_record.h
979814
index 697cea4..c07d1fa 100644
979814
--- libsepol-2.5/include/sepol/port_record.h
979814
+++ libsepol-2.5/include/sepol/port_record.h
979814
@@ -14,6 +14,7 @@ typedef struct sepol_port_key sepol_port_key_t;
979814
 
979814
 #define SEPOL_PROTO_UDP 0
979814
 #define SEPOL_PROTO_TCP 1
979814
+#define SEPOL_PROTO_DCCP 2
979814
 
979814
 /* Key */
979814
 extern int sepol_port_compare(const sepol_port_t * port,
979814
diff --git libsepol-2.5/src/Makefile libsepol-2.5/src/Makefile
979814
index db6c2ba..b0c901f 100644
979814
--- libsepol-2.5/src/Makefile
979814
+++ libsepol-2.5/src/Makefile
979814
@@ -18,15 +18,15 @@ TARGET=libsepol.so
979814
 LIBPC=libsepol.pc
979814
 LIBMAP=libsepol.map
979814
 LIBSO=$(TARGET).$(LIBVERSION)
979814
-OBJS= $(patsubst %.c,%.o,$(wildcard *.c))
979814
-LOBJS= $(patsubst %.c,%.lo,$(wildcard *.c))
979814
+OBJS= $(patsubst %.c,%.o,$(sort $(wildcard *.c)))
979814
+LOBJS= $(patsubst %.c,%.lo,$(sort $(wildcard *.c)))
979814
 CFLAGS ?= -Werror -Wall -W -Wundef -Wshadow -Wmissing-format-attribute -O2
979814
 
979814
 override CFLAGS += -I. -I../include -D_GNU_SOURCE
979814
 
979814
 ifneq ($(DISABLE_CIL),y)
979814
-OBJS += $(sort $(patsubst %.c,%.o,$(wildcard $(CILDIR)/src/*.c) $(CIL_GENERATED)))
979814
-LOBJS += $(sort $(patsubst %.c,%.lo,$(wildcard $(CILDIR)/src/*.c) $(CIL_GENERATED)))
979814
+OBJS += $(sort $(patsubst %.c,%.o,$(sort $(wildcard $(CILDIR)/src/*.c)) $(CIL_GENERATED)))
979814
+LOBJS += $(sort $(patsubst %.c,%.lo,$(sort $(wildcard $(CILDIR)/src/*.c)) $(CIL_GENERATED)))
979814
 override CFLAGS += -I$(CILDIR)/include
979814
 endif
979814
 
979814
@@ -76,7 +76,7 @@ relabel:
979814
 	/sbin/restorecon $(SHLIBDIR)/$(LIBSO)
979814
 
979814
 clean: 
979814
-	-rm -f $(LIBPC) $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(TARGET) $(CIL_GENERATED)
979814
+	-rm -f $(LIBPC) $(LIBMAP) $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(TARGET) $(CIL_GENERATED)
979814
 
979814
 indent:
979814
 	../../scripts/Lindent $(wildcard *.[ch])
979814
diff --git libsepol-2.5/src/assertion.c libsepol-2.5/src/assertion.c
979814
index fbf397f..a4be880 100644
979814
--- libsepol-2.5/src/assertion.c
979814
+++ libsepol-2.5/src/assertion.c
979814
@@ -147,36 +147,49 @@ static int report_assertion_extended_permissions(sepol_handle_t *handle,
979814
 	avtab_key_t tmp_key;
979814
 	avtab_extended_perms_t *xperms;
979814
 	avtab_extended_perms_t error;
979814
+	ebitmap_t *sattr = &p->type_attr_map[stype];
979814
+	ebitmap_t *tattr = &p->type_attr_map[ttype];
979814
+	ebitmap_node_t *snode, *tnode;
979814
+	unsigned int i, j;
979814
 	int rc = 1;
979814
 	int ret = 0;
979814
 
979814
 	memcpy(&tmp_key, k, sizeof(avtab_key_t));
979814
 	tmp_key.specified = AVTAB_XPERMS_ALLOWED;
979814
 
979814
-	for (node = avtab_search_node(avtab, &tmp_key);
979814
-	     node;
979814
-	     node = avtab_search_node_next(node, tmp_key.specified)) {
979814
-		xperms = node->datum.xperms;
979814
-		if ((xperms->specified != AVTAB_XPERMS_IOCTLFUNCTION)
979814
-				&& (xperms->specified != AVTAB_XPERMS_IOCTLDRIVER))
979814
+	ebitmap_for_each_bit(sattr, snode, i) {
979814
+		if (!ebitmap_node_get_bit(snode, i))
979814
 			continue;
979814
+		ebitmap_for_each_bit(tattr, tnode, j) {
979814
+			if (!ebitmap_node_get_bit(tnode, j))
979814
+				continue;
979814
+			tmp_key.source_type = i + 1;
979814
+			tmp_key.target_type = j + 1;
979814
+			for (node = avtab_search_node(avtab, &tmp_key);
979814
+			     node;
979814
+			     node = avtab_search_node_next(node, tmp_key.specified)) {
979814
+				xperms = node->datum.xperms;
979814
+				if ((xperms->specified != AVTAB_XPERMS_IOCTLFUNCTION)
979814
+						&& (xperms->specified != AVTAB_XPERMS_IOCTLDRIVER))
979814
+					continue;
979814
 
979814
-		rc = check_extended_permissions(avrule->xperms, xperms);
979814
-		/* failure on the extended permission check_extended_permissionss */
979814
-		if (rc) {
979814
-			extended_permissions_violated(&error, avrule->xperms, xperms);
979814
-			ERR(handle, "neverallowxperm on line %lu of %s (or line %lu of policy.conf) violated by\n"
979814
-					"allowxperm %s %s:%s %s;",
979814
-					avrule->source_line, avrule->source_filename, avrule->line,
979814
-					p->p_type_val_to_name[stype],
979814
-					p->p_type_val_to_name[ttype],
979814
-					p->p_class_val_to_name[curperm->tclass - 1],
979814
-					sepol_extended_perms_to_string(&error));
979814
-
979814
-			rc = 0;
979814
-			ret++;
979814
+				rc = check_extended_permissions(avrule->xperms, xperms);
979814
+				/* failure on the extended permission check_extended_permissions */
979814
+				if (rc) {
979814
+					extended_permissions_violated(&error, avrule->xperms, xperms);
979814
+					ERR(handle, "neverallowxperm on line %lu of %s (or line %lu of policy.conf) violated by\n"
979814
+							"allowxperm %s %s:%s %s;",
979814
+							avrule->source_line, avrule->source_filename, avrule->line,
979814
+							p->p_type_val_to_name[i],
979814
+							p->p_type_val_to_name[j],
979814
+							p->p_class_val_to_name[curperm->tclass - 1],
979814
+							sepol_extended_perms_to_string(&error));
979814
+
979814
+					rc = 0;
979814
+					ret++;
979814
+				}
979814
+			}
979814
 		}
979814
-
979814
 	}
979814
 
979814
 	/* failure on the regular permissions */
979814
@@ -304,9 +317,57 @@ oom:
979814
 }
979814
 
979814
 /*
979814
- * If the ioctl permission is granted in check_assertion_avtab_match for the
979814
- * source/target/class matching the current avrule neverallow, a lookup is
979814
- * performed to determine if extended permissions exist for the source/target/class.
979814
+ * Look up the extended permissions in avtab and verify that neverallowed
979814
+ * permissions are not granted.
979814
+ */
979814
+static int check_assertion_extended_permissions_avtab(avrule_t *avrule, avtab_t *avtab,
979814
+						unsigned int stype, unsigned int ttype,
979814
+						avtab_key_t *k, policydb_t *p)
979814
+{
979814
+	avtab_ptr_t node;
979814
+	avtab_key_t tmp_key;
979814
+	avtab_extended_perms_t *xperms;
979814
+	av_extended_perms_t *neverallow_xperms = avrule->xperms;
979814
+	ebitmap_t *sattr = &p->type_attr_map[stype];
979814
+	ebitmap_t *tattr = &p->type_attr_map[ttype];
979814
+	ebitmap_node_t *snode, *tnode;
979814
+	unsigned int i, j;
979814
+	int rc = 1;
979814
+
979814
+	memcpy(&tmp_key, k, sizeof(avtab_key_t));
979814
+	tmp_key.specified = AVTAB_XPERMS_ALLOWED;
979814
+
979814
+	ebitmap_for_each_bit(sattr, snode, i) {
979814
+		if (!ebitmap_node_get_bit(snode, i))
979814
+			continue;
979814
+		ebitmap_for_each_bit(tattr, tnode, j) {
979814
+			if (!ebitmap_node_get_bit(tnode, j))
979814
+				continue;
979814
+			tmp_key.source_type = i + 1;
979814
+			tmp_key.target_type = j + 1;
979814
+			for (node = avtab_search_node(avtab, &tmp_key);
979814
+			     node;
979814
+			     node = avtab_search_node_next(node, tmp_key.specified)) {
979814
+				xperms = node->datum.xperms;
979814
+
979814
+				if ((xperms->specified != AVTAB_XPERMS_IOCTLFUNCTION)
979814
+						&& (xperms->specified != AVTAB_XPERMS_IOCTLDRIVER))
979814
+					continue;
979814
+				rc = check_extended_permissions(neverallow_xperms, xperms);
979814
+				if (rc)
979814
+					break;
979814
+			}
979814
+		}
979814
+	}
979814
+
979814
+	return rc;
979814
+}
979814
+
979814
+/*
979814
+ * When the ioctl permission is granted on an avtab entry that matches an
979814
+ * avrule neverallowxperm entry, enumerate over the matching
979814
+ * source/target/class sets to determine if the extended permissions exist
979814
+ * and if the neverallowed ioctls are granted.
979814
  *
979814
  * Four scenarios of interest:
979814
  * 1. PASS - the ioctl permission is not granted for this source/target/class
979814
@@ -319,33 +380,72 @@ oom:
979814
  *    granted
979814
  */
979814
 static int check_assertion_extended_permissions(avrule_t *avrule, avtab_t *avtab,
979814
-						avtab_key_t *k)
979814
+						avtab_key_t *k, policydb_t *p)
979814
 {
979814
-	avtab_ptr_t node;
979814
-	avtab_key_t tmp_key;
979814
-	avtab_extended_perms_t *xperms;
979814
-	av_extended_perms_t *neverallow_xperms = avrule->xperms;
979814
-	int rc = 1;
979814
+	ebitmap_t src_matches, tgt_matches, matches;
979814
+	unsigned int i, j;
979814
+	ebitmap_node_t *snode, *tnode;
979814
+	class_perm_node_t *cp;
979814
+	int rc;
979814
+	int ret = 1;
979814
 
979814
-	memcpy(&tmp_key, k, sizeof(avtab_key_t));
979814
-	tmp_key.specified = AVTAB_XPERMS_ALLOWED;
979814
+	ebitmap_init(&src_matches);
979814
+	ebitmap_init(&tgt_matches);
979814
+	ebitmap_init(&matches);
979814
+	rc = ebitmap_and(&src_matches, &avrule->stypes.types,
979814
+			 &p->attr_type_map[k->source_type - 1]);
979814
+	if (rc)
979814
+		goto oom;
979814
 
979814
-	for (node = avtab_search_node(avtab, &tmp_key);
979814
-	     node;
979814
-	     node = avtab_search_node_next(node, tmp_key.specified)) {
979814
-		xperms = node->datum.xperms;
979814
-		if ((xperms->specified != AVTAB_XPERMS_IOCTLFUNCTION)
979814
-				&& (xperms->specified != AVTAB_XPERMS_IOCTLDRIVER))
979814
-			continue;
979814
+	if (ebitmap_length(&src_matches) == 0)
979814
+		goto exit;
979814
 
979814
-		rc = check_extended_permissions(neverallow_xperms, xperms);
979814
+	if (avrule->flags == RULE_SELF) {
979814
+		rc = ebitmap_and(&matches, &p->attr_type_map[k->source_type - 1],
979814
+				&p->attr_type_map[k->target_type - 1]);
979814
 		if (rc)
979814
-			break;
979814
+			goto oom;
979814
+		rc = ebitmap_and(&tgt_matches, &avrule->stypes.types, &matches);
979814
+		if (rc)
979814
+			goto oom;
979814
+	} else {
979814
+		rc = ebitmap_and(&tgt_matches, &avrule->ttypes.types,
979814
+				&p->attr_type_map[k->target_type -1]);
979814
+		if (rc)
979814
+			goto oom;
979814
 	}
979814
 
979814
-	return rc;
979814
-}
979814
+	if (ebitmap_length(&tgt_matches) == 0)
979814
+		goto exit;
979814
 
979814
+	for (cp = avrule->perms; cp; cp = cp->next) {
979814
+		if (cp->tclass != k->target_class)
979814
+			continue;
979814
+		ebitmap_for_each_bit(&src_matches, snode, i) {
979814
+			if (!ebitmap_node_get_bit(snode, i))
979814
+				continue;
979814
+			ebitmap_for_each_bit(&tgt_matches, tnode, j) {
979814
+				if (!ebitmap_node_get_bit(tnode, j))
979814
+					continue;
979814
+
979814
+				ret = check_assertion_extended_permissions_avtab(
979814
+						avrule, avtab, i, j, k, p);
979814
+				if (ret)
979814
+					goto exit;
979814
+			}
979814
+		}
979814
+	}
979814
+	goto exit;
979814
+
979814
+oom:
979814
+	ERR(NULL, "Out of memory - unable to check neverallows");
979814
+
979814
+exit:
979814
+	ebitmap_destroy(&src_matches);
979814
+	ebitmap_destroy(&tgt_matches);
979814
+	ebitmap_destroy(&matches);
979814
+	return ret;
979814
+}
979814
 
979814
 static int check_assertion_avtab_match(avtab_key_t *k, avtab_datum_t *d, void *args)
979814
 {
979814
@@ -355,7 +455,7 @@ static int check_assertion_avtab_match(avtab_key_t *k, avtab_datum_t *d, void *a
979814
 	avrule_t *avrule = a->avrule;
979814
 	avtab_t *avtab = a->avtab;
979814
 
979814
-	if (k->specified != AVTAB_ALLOWED && k->specified != AVTAB_XPERMS_ALLOWED)
979814
+	if (k->specified != AVTAB_ALLOWED)
979814
 		goto exit;
979814
 
979814
 	if (!match_any_class_permissions(avrule->perms, k->target_class, d->data))
979814
@@ -386,7 +486,7 @@ static int check_assertion_avtab_match(avtab_key_t *k, avtab_datum_t *d, void *a
979814
 		goto exit;
979814
 
979814
 	if (avrule->specified == AVRULE_XPERMS_NEVERALLOW) {
979814
-		rc = check_assertion_extended_permissions(avrule, avtab, k);
979814
+		rc = check_assertion_extended_permissions(avrule, avtab, k, p);
979814
 		if (rc == 0)
979814
 			goto exit;
979814
 	}
979814
diff --git libsepol-2.5/src/expand.c libsepol-2.5/src/expand.c
979814
index 9cb7965..0ad57f5 100644
979814
--- libsepol-2.5/src/expand.c
979814
+++ libsepol-2.5/src/expand.c
979814
@@ -2497,6 +2497,7 @@ int type_set_expand(type_set_t * set, ebitmap_t * t, policydb_t * p,
979814
 	unsigned int i;
979814
 	ebitmap_t types, neg_types;
979814
 	ebitmap_node_t *tnode;
979814
+	int rc =-1;
979814
 
979814
 	ebitmap_init(&types);
979814
 	ebitmap_init(t);
979814
@@ -2505,17 +2506,25 @@ int type_set_expand(type_set_t * set, ebitmap_t * t, policydb_t * p,
979814
 		/* First go through the types and OR all the attributes to types */
979814
 		ebitmap_for_each_bit(&set->types, tnode, i) {
979814
 			if (ebitmap_node_get_bit(tnode, i)) {
979814
+
979814
+				/*
979814
+				 * invalid policies might have more types set in the ebitmap than
979814
+				 * what's available in the type_val_to_struct mapping
979814
+				 */
979814
+				if (i > p->p_types.nprim - 1)
979814
+					goto err_types;
979814
+
979814
 				if (p->type_val_to_struct[i]->flavor ==
979814
 				    TYPE_ATTRIB) {
979814
 					if (ebitmap_union
979814
 					    (&types,
979814
 					     &p->type_val_to_struct[i]->
979814
 					     types)) {
979814
-						return -1;
979814
+						goto err_types;
979814
 					}
979814
 				} else {
979814
 					if (ebitmap_set_bit(&types, i, 1)) {
979814
-						return -1;
979814
+						goto err_types;
979814
 					}
979814
 				}
979814
 			}
979814
@@ -2523,7 +2532,7 @@ int type_set_expand(type_set_t * set, ebitmap_t * t, policydb_t * p,
979814
 	} else {
979814
 		/* No expansion of attributes, just copy the set as is. */
979814
 		if (ebitmap_cpy(&types, &set->types))
979814
-			return -1;
979814
+			goto err_types;
979814
 	}
979814
 
979814
 	/* Now do the same thing for negset */
979814
@@ -2535,11 +2544,11 @@ int type_set_expand(type_set_t * set, ebitmap_t * t, policydb_t * p,
979814
 				if (ebitmap_union
979814
 				    (&neg_types,
979814
 				     &p->type_val_to_struct[i]->types)) {
979814
-					return -1;
979814
+					goto err_neg;
979814
 				}
979814
 			} else {
979814
 				if (ebitmap_set_bit(&neg_types, i, 1)) {
979814
-					return -1;
979814
+					goto err_neg;
979814
 				}
979814
 			}
979814
 		}
979814
@@ -2554,7 +2563,7 @@ int type_set_expand(type_set_t * set, ebitmap_t * t, policydb_t * p,
979814
 			    p->type_val_to_struct[i]->flavor == TYPE_ATTRIB)
979814
 				continue;
979814
 			if (ebitmap_set_bit(t, i, 1))
979814
-				return -1;
979814
+				goto err_neg;
979814
 		}
979814
 		goto out;
979814
 	}
979814
@@ -2563,7 +2572,7 @@ int type_set_expand(type_set_t * set, ebitmap_t * t, policydb_t * p,
979814
 		if (ebitmap_node_get_bit(tnode, i)
979814
 		    && (!ebitmap_get_bit(&neg_types, i)))
979814
 			if (ebitmap_set_bit(t, i, 1))
979814
-				return -1;
979814
+				goto err_neg;
979814
 	}
979814
 
979814
 	if (set->flags & TYPE_COMP) {
979814
@@ -2575,20 +2584,23 @@ int type_set_expand(type_set_t * set, ebitmap_t * t, policydb_t * p,
979814
 			}
979814
 			if (ebitmap_get_bit(t, i)) {
979814
 				if (ebitmap_set_bit(t, i, 0))
979814
-					return -1;
979814
+					goto err_neg;
979814
 			} else {
979814
 				if (ebitmap_set_bit(t, i, 1))
979814
-					return -1;
979814
+					goto err_neg;
979814
 			}
979814
 		}
979814
 	}
979814
 
979814
-      out:
979814
+	  out:
979814
+	rc = 0;
979814
 
979814
-	ebitmap_destroy(&types);
979814
+	  err_neg:
979814
 	ebitmap_destroy(&neg_types);
979814
+	  err_types:
979814
+	ebitmap_destroy(&types);
979814
 
979814
-	return 0;
979814
+	return rc;
979814
 }
979814
 
979814
 static int copy_neverallow(policydb_t * dest_pol, uint32_t * typemap,
979814
diff --git libsepol-2.5/src/genbools.c libsepol-2.5/src/genbools.c
979814
index 6a06ec9..c81e848 100644
979814
--- libsepol-2.5/src/genbools.c
979814
+++ libsepol-2.5/src/genbools.c
979814
@@ -79,7 +79,7 @@ static int load_booleans(struct policydb *policydb, const char *path,
979814
 	if (boolf == NULL)
979814
 		goto localbool;
979814
 
979814
-#ifdef DARWIN
979814
+#ifdef __APPLE__
979814
         if ((buffer = (char *)malloc(255 * sizeof(char))) == NULL) {
979814
           ERR(NULL, "out of memory");
979814
 	  return -1;
979814
@@ -111,7 +111,7 @@ static int load_booleans(struct policydb *policydb, const char *path,
979814
 	boolf = fopen(localbools, "r");
979814
 	if (boolf != NULL) {
979814
 
979814
-#ifdef DARWIN
979814
+#ifdef __APPLE__
979814
 
979814
 	  while(fgets(buffer, 255, boolf) != NULL) {
979814
 #else
979814
diff --git libsepol-2.5/src/genusers.c libsepol-2.5/src/genusers.c
979814
index 7826b71..0b98a76 100644
979814
--- libsepol-2.5/src/genusers.c
979814
+++ libsepol-2.5/src/genusers.c
979814
@@ -7,7 +7,7 @@
979814
 
979814
 #include <sepol/policydb/policydb.h>
979814
 
979814
-#ifndef DARWIN
979814
+#ifndef __APPLE__
979814
 #include <stdio_ext.h>
979814
 #endif
979814
 
979814
@@ -47,7 +47,7 @@ static int load_users(struct policydb *policydb, const char *path)
979814
 	if (fp == NULL)
979814
 		return -1;
979814
 
979814
-#ifdef DARWIN
979814
+#ifdef __APPLE__
979814
 	if ((buffer = (char *)malloc(255 * sizeof(char))) == NULL) {
979814
 	  ERR(NULL, "out of memory");
979814
 	  return -1;
979814
diff --git libsepol-2.5/src/hierarchy.c libsepol-2.5/src/hierarchy.c
979814
index 6f73195..778541a 100644
979814
--- libsepol-2.5/src/hierarchy.c
979814
+++ libsepol-2.5/src/hierarchy.c
979814
@@ -121,18 +121,6 @@ static int bounds_expand_rule(sepol_handle_t *handle, policydb_t *p,
979814
 		}
979814
 	}
979814
 
979814
-	if (ebitmap_get_bit(&p->attr_type_map[tgt - 1], parent - 1)) {
979814
-		avtab_key.target_type = parent;
979814
-		ebitmap_for_each_bit(&p->attr_type_map[src - 1], tnode, i) {
979814
-			if (!ebitmap_node_get_bit(tnode, i))
979814
-				continue;
979814
-			avtab_key.source_type = i + 1;
979814
-			rc = bounds_insert_rule(handle, avtab, global, other,
979814
-						&avtab_key, &datum);
979814
-			if (rc) goto exit;
979814
-		}
979814
-	}
979814
-
979814
 exit:
979814
 	return rc;
979814
 }
979814
@@ -313,45 +301,21 @@ static int bounds_check_rule(sepol_handle_t *handle, policydb_t *p,
979814
 		ebitmap_for_each_bit(&p->attr_type_map[tgt - 1], tnode, i) {
979814
 			if (!ebitmap_node_get_bit(tnode, i))
979814
 				continue;
979814
-			avtab_key.target_type = i + 1;
979814
-			d = bounds_not_covered(global_avtab, cur_avtab,
979814
-					       &avtab_key, data);
979814
-			if (!d) continue;
979814
 			td = p->type_val_to_struct[i];
979814
 			if (td && td->bounds) {
979814
 				avtab_key.target_type = td->bounds;
979814
 				d = bounds_not_covered(global_avtab, cur_avtab,
979814
 						       &avtab_key, data);
979814
-				if (!d) continue;
979814
-			}
979814
-			(*numbad)++;
979814
-			rc = bounds_add_bad(handle, child, i+1, class, d, bad);
979814
-			if (rc) goto exit;
979814
-		}
979814
-	}
979814
-	if (ebitmap_get_bit(&p->attr_type_map[tgt - 1], child - 1)) {
979814
-		avtab_key.target_type = parent;
979814
-		ebitmap_for_each_bit(&p->attr_type_map[src - 1], tnode, i) {
979814
-			if (!ebitmap_node_get_bit(tnode, i))
979814
-				continue;
979814
-			avtab_key.source_type = i + 1;
979814
-			if (avtab_key.source_type == child) {
979814
-				/* Checked above */
979814
-				continue;
979814
-			}
979814
-			d = bounds_not_covered(global_avtab, cur_avtab,
979814
-					       &avtab_key, data);
979814
-			if (!d) continue;
979814
-			td = p->type_val_to_struct[i];
979814
-			if (td && td->bounds) {
979814
-				avtab_key.source_type = td->bounds;
979814
+			} else {
979814
+				avtab_key.target_type = i + 1;
979814
 				d = bounds_not_covered(global_avtab, cur_avtab,
979814
 						       &avtab_key, data);
979814
-				if (!d) continue;
979814
 			}
979814
-			(*numbad)++;
979814
-			rc = bounds_add_bad(handle, i+1, child, class, d, bad);
979814
-			if (rc) goto exit;
979814
+			if (d) {
979814
+				(*numbad)++;
979814
+				rc = bounds_add_bad(handle, child, i+1, class, d, bad);
979814
+				if (rc) goto exit;
979814
+			}
979814
 		}
979814
 	}
979814
 
979814
diff --git libsepol-2.5/src/module_to_cil.c libsepol-2.5/src/module_to_cil.c
979814
index 18ec6b9..36f3b7d 100644
979814
--- libsepol-2.5/src/module_to_cil.c
979814
+++ libsepol-2.5/src/module_to_cil.c
979814
@@ -26,6 +26,9 @@
979814
 #include <getopt.h>
979814
 #include <libgen.h>
979814
 #include <netinet/in.h>
979814
+#ifndef IPPROTO_DCCP
979814
+#define IPPROTO_DCCP 33
979814
+#endif
979814
 #include <signal.h>
979814
 #include <stdarg.h>
979814
 #include <stdio.h>
979814
@@ -1070,6 +1073,10 @@ static int avrule_list_to_cil(int indent, struct policydb *pdb, struct avrule *a
979814
 	struct type_set *ts;
979814
 
979814
 	for (avrule = avrule_list; avrule != NULL; avrule = avrule->next) {
979814
+		if (avrule->specified == AVRULE_NEVERALLOW && avrule->source_filename) {
979814
+			cil_println(0, ";;* lmx %lu %s\n",avrule->source_line, avrule->source_filename);
979814
+		}
979814
+
979814
 		ts = &avrule->stypes;
979814
 		rc = process_typeset(indent, pdb, ts, attr_list, &snames, &num_snames);
979814
 		if (rc != 0) {
979814
@@ -1100,6 +1107,10 @@ static int avrule_list_to_cil(int indent, struct policydb *pdb, struct avrule *a
979814
 
979814
 		names_destroy(&snames, &num_snames);
979814
 		names_destroy(&tnames, &num_tnames);
979814
+
979814
+		if (avrule->specified == AVRULE_NEVERALLOW && avrule->source_filename) {
979814
+			cil_println(0, ";;* lme\n");
979814
+		}
979814
 	}
979814
 
979814
 	return 0;
979814
@@ -1292,7 +1303,7 @@ static int cond_list_to_cil(int indent, struct policydb *pdb, struct cond_node *
979814
 {
979814
 	int rc = -1;
979814
 	struct cond_node *cond;
979814
-	struct list *attr_list;
979814
+	struct list *attr_list = NULL;
979814
 
979814
 	rc = list_init(&attr_list);
979814
 	if (rc != 0) {
979814
@@ -2537,6 +2548,7 @@ static int ocontext_selinux_port_to_cil(struct policydb *pdb, struct ocontext *p
979814
 		switch (portcon->u.port.protocol) {
979814
 		case IPPROTO_TCP: protocol = "tcp"; break;
979814
 		case IPPROTO_UDP: protocol = "udp"; break;
979814
+		case IPPROTO_DCCP: protocol = "dccp"; break;
979814
 		default:
979814
 			log_err("Unknown portcon protocol: %i", portcon->u.port.protocol);
979814
 			rc = -1;
979814
@@ -3470,7 +3482,7 @@ static int block_to_cil(struct policydb *pdb, struct avrule_block *block, struct
979814
 {
979814
 	int rc = -1;
979814
 	struct avrule_decl *decl;
979814
-	struct list *attr_list;
979814
+	struct list *attr_list = NULL;
979814
 
979814
 	decl = block->branch_list;
979814
 
979814
@@ -3619,7 +3631,7 @@ static int blocks_to_cil(struct policydb *pdb)
979814
 	int rc = -1;
979814
 	struct avrule_block *block;
979814
 	int indent = 0;
979814
-	struct stack *stack;
979814
+	struct stack *stack = NULL;
979814
 
979814
 	rc = stack_init(&stack);
979814
 	if (rc != 0) {
979814
@@ -3687,7 +3699,7 @@ static int linked_blocks_to_cil(struct policydb *pdb)
979814
 	// Since it is linked, all optional blocks have been resolved
979814
 	int rc = -1;
979814
 	struct avrule_block *block;
979814
-	struct stack *stack;
979814
+	struct stack *stack = NULL;
979814
 
979814
 	rc = stack_init(&stack);
979814
 	if (rc != 0) {
979814
diff --git libsepol-2.5/src/node_record.c libsepol-2.5/src/node_record.c
979814
index bd48ba0..21043b6 100644
979814
--- libsepol-2.5/src/node_record.c
979814
+++ libsepol-2.5/src/node_record.c
979814
@@ -70,7 +70,7 @@ static int node_parse_addr(sepol_handle_t * handle,
979814
 				return STATUS_ERR;
979814
 			}
979814
 
979814
-#ifdef DARWIN
979814
+#ifdef __APPLE__
979814
 			memcpy(addr_bytes, in_addr.s6_addr, 16);
979814
 #else
979814
 			memcpy(addr_bytes, in_addr.s6_addr32, 16);
979814
@@ -162,7 +162,7 @@ static int node_expand_addr(sepol_handle_t * handle,
979814
 		{
979814
 			struct in6_addr addr;
979814
 			memset(&addr, 0, sizeof(struct in6_addr));
979814
-#ifdef DARWIN
979814
+#ifdef __APPLE__
979814
 			memcpy(&addr.s6_addr[0], addr_bytes, 16);
979814
 #else
979814
 			memcpy(&addr.s6_addr32[0], addr_bytes, 16);
979814
diff --git libsepol-2.5/src/nodes.c libsepol-2.5/src/nodes.c
979814
index 50cf21d..820346d 100644
979814
--- libsepol-2.5/src/nodes.c
979814
+++ libsepol-2.5/src/nodes.c
979814
@@ -273,6 +273,7 @@ int sepol_node_query(sepol_handle_t * handle,
979814
 							   c, SEPOL_PROTO_IP6,
979814
 							   response) < 0)
979814
 						goto err;
979814
+					return STATUS_SUCCESS;
979814
 				}
979814
 			}
979814
 			break;
979814
diff --git libsepol-2.5/src/port_record.c libsepol-2.5/src/port_record.c
979814
index 6a33d93..ed9093b 100644
979814
--- libsepol-2.5/src/port_record.c
979814
+++ libsepol-2.5/src/port_record.c
979814
@@ -184,6 +184,8 @@ const char *sepol_port_get_proto_str(int proto)
979814
 		return "udp";
979814
 	case SEPOL_PROTO_TCP:
979814
 		return "tcp";
979814
+	case SEPOL_PROTO_DCCP:
979814
+		return "dccp";
979814
 	default:
979814
 		return "???";
979814
 	}
979814
diff --git libsepol-2.5/src/ports.c libsepol-2.5/src/ports.c
979814
index 607a629..62ec602 100644
979814
--- libsepol-2.5/src/ports.c
979814
+++ libsepol-2.5/src/ports.c
979814
@@ -1,4 +1,7 @@
979814
 #include <netinet/in.h>
979814
+#ifndef IPPROTO_DCCP
979814
+#define IPPROTO_DCCP 33
979814
+#endif
979814
 #include <stdlib.h>
979814
 
979814
 #include "debug.h"
979814
@@ -16,6 +19,8 @@ static inline int sepol2ipproto(sepol_handle_t * handle, int proto)
979814
 		return IPPROTO_TCP;
979814
 	case SEPOL_PROTO_UDP:
979814
 		return IPPROTO_UDP;
979814
+	case SEPOL_PROTO_DCCP:
979814
+		return IPPROTO_DCCP;
979814
 	default:
979814
 		ERR(handle, "unsupported protocol %u", proto);
979814
 		return STATUS_ERR;
979814
@@ -30,6 +35,8 @@ static inline int ipproto2sepol(sepol_handle_t * handle, int proto)
979814
 		return SEPOL_PROTO_TCP;
979814
 	case IPPROTO_UDP:
979814
 		return SEPOL_PROTO_UDP;
979814
+	case IPPROTO_DCCP:
979814
+		return SEPOL_PROTO_DCCP;
979814
 	default:
979814
 		ERR(handle, "invalid protocol %u " "found in policy", proto);
979814
 		return STATUS_ERR;
979814
diff --git libsepol-2.5/src/private.h libsepol-2.5/src/private.h
979814
index 8a6d4bb..9c700c9 100644
979814
--- libsepol-2.5/src/private.h
979814
+++ libsepol-2.5/src/private.h
979814
@@ -5,7 +5,7 @@
979814
 #include <sepol/policydb/policydb.h>
979814
 
979814
 
979814
-#ifdef DARWIN
979814
+#ifdef __APPLE__
979814
 #include <sys/types.h>
979814
 #include <machine/endian.h>
979814
 #else
979814
@@ -16,7 +16,7 @@
979814
 #include <errno.h>
979814
 #include <dso.h>
979814
 
979814
-#ifdef DARWIN
979814
+#ifdef __APPLE__
979814
 #define __BYTE_ORDER  BYTE_ORDER
979814
 #define __LITTLE_ENDIAN  LITTLE_ENDIAN
979814
 #endif
979814
diff --git libsepol-2.5/src/services.c libsepol-2.5/src/services.c
979814
index d64a8e8..d2b80b4 100644
979814
--- libsepol-2.5/src/services.c
979814
+++ libsepol-2.5/src/services.c
979814
@@ -1152,20 +1152,16 @@ int hidden sepol_compute_av(sepol_security_id_t ssid,
979814
 int hidden sepol_string_to_security_class(const char *class_name,
979814
 			sepol_security_class_t *tclass)
979814
 {
979814
-	char *class = NULL;
979814
-	sepol_security_class_t id;
979814
-
979814
-	for (id = 1;; id++) {
979814
-		class = policydb->p_class_val_to_name[id - 1];
979814
-		if (class == NULL) {
979814
-			ERR(NULL, "could not convert %s to class id", class_name);
979814
-			return STATUS_ERR;
979814
-		}
979814
-		if ((strcmp(class, class_name)) == 0) {
979814
-			*tclass = id;
979814
-			return STATUS_SUCCESS;
979814
-		}
979814
+	class_datum_t *tclass_datum;
979814
+
979814
+	tclass_datum = hashtab_search(policydb->p_classes.table,
979814
+				      (hashtab_key_t) class_name);
979814
+	if (!tclass_datum) {
979814
+		ERR(NULL, "unrecognized class %s", class_name);
979814
+		return STATUS_ERR;
979814
 	}
979814
+	*tclass = tclass_datum->s.value;
979814
+	return STATUS_SUCCESS;
979814
 }
979814
 
979814
 /*
979814
diff --git libsepol-2.5/tests/.gitignore libsepol-2.5/tests/.gitignore
979814
new file mode 100644
979814
index 0000000..c3f60fd
979814
--- /dev/null
979814
+++ libsepol-2.5/tests/.gitignore
979814
@@ -0,0 +1 @@
979814
+libsepol-tests
979814
diff --git libsepol-2.5/tests/policies/.gitignore libsepol-2.5/tests/policies/.gitignore
979814
new file mode 100644
979814
index 0000000..5a547a8
979814
--- /dev/null
979814
+++ libsepol-2.5/tests/policies/.gitignore
979814
@@ -0,0 +1,3 @@
979814
+test-downgrade/
979814
+test-*/*.mls
979814
+test-*/*.std