Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Jun 2002 07:44:10 -0700 (PDT)
From:      Robert Watson <rwatson@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 13372 for review
Message-ID:  <200206241444.g5OEiAm41914@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://people.freebsd.org/~peter/p4db/chv.cgi?CH=13372

Change 13372 by rwatson@rwatson_tislabs on 2002/06/24 07:43:16

	Let mac_update_vnode_from_externalized() return a failure so that
	invalid labels are ignored.

Affected files ...

... //depot/projects/trustedbsd/mac/sys/kern/kern_mac.c#151 edit
... //depot/projects/trustedbsd/mac/sys/security/mac_biba/mac_biba.c#50 edit
... //depot/projects/trustedbsd/mac/sys/security/mac_mls/mac_mls.c#36 edit
... //depot/projects/trustedbsd/mac/sys/security/mac_none/mac_none.c#30 edit
... //depot/projects/trustedbsd/mac/sys/security/mac_test/mac_test.c#3 edit
... //depot/projects/trustedbsd/mac/sys/sys/mac_policy.h#65 edit

Differences ...

==== //depot/projects/trustedbsd/mac/sys/kern/kern_mac.c#151 (text+ko) ====

@@ -853,11 +853,14 @@
  * Given an externalized mac label, internalize it and stamp it on a
  * vnode.
  */
-static void
+static int
 mac_update_vnode_from_externalized(struct vnode *vp, struct mac *extmac)
 {
+	int error;
 
-	MAC_PERFORM(update_vnode_from_externalized, vp, &vp->v_label, extmac);
+	MAC_CHECK(update_vnode_from_externalized, vp, &vp->v_label, extmac);
+
+	return (error);
 }
 
 /*
@@ -905,8 +908,10 @@
 	}
 
 	if (buflen == sizeof(extmac))
-		mac_update_vnode_from_externalized(vp, &extmac);
-	else {
+		error = EPERM;		/* Fail very closed. */
+	if (error == 0)
+		error = mac_update_vnode_from_externalized(vp, &extmac);
+	if (error) {
 		if (mac_debug_label_fallback) {
 			printf("Corrupted label, falling back.\n");
 			mac_update_vnode_from_mount(vp, vp->v_mount);

==== //depot/projects/trustedbsd/mac/sys/security/mac_biba/mac_biba.c#50 (text+ko) ====

@@ -704,17 +704,26 @@
 	mac_biba_copy_single(source, dest);
 }
 
-static void
+static int
 mac_biba_update_vnode_from_externalized(struct vnode *vp,
     struct label *vnodelabel, struct mac *extmac)
 {
 	struct mac_biba *source, *dest;
+	int error;
 
-	/* XXX: Validity check. */
 	source = &extmac->m_biba;
 	dest = SLOT(vnodelabel);
 
+	error = mac_biba_valid(source);
+	if (error)
+		return (error);
+
+	if ((source->mb_flags & MAC_BIBA_FLAGS_BOTH) != MAC_BIBA_FLAG_SINGLE)
+		return (EINVAL);
+
 	mac_biba_copy_single(source, dest);
+
+	return (0);
 }
 
 static void

==== //depot/projects/trustedbsd/mac/sys/security/mac_mls/mac_mls.c#36 (text+ko) ====

@@ -689,17 +689,26 @@
 	mac_mls_copy_single(source, dest);
 }
 
-static void
+static int
 mac_mls_update_vnode_from_externalized(struct vnode *vp,
     struct label *vnodelabel, struct mac *extmac)
 {
 	struct mac_mls *source, *dest;
+	int error;
 
-	/* XXX: Validity check. */
 	source = &extmac->m_mls;
 	dest = SLOT(vnodelabel);
 
+	error = mac_mls_valid(source);
+	if (error)
+		return (error);
+
+	if ((source->mm_flags & MAC_MLS_FLAGS_BOTH) != MAC_MLS_FLAG_SINGLE)
+		return (EINVAL);
+
 	mac_mls_copy_single(source, dest);
+
+	return (0);
 }
 
 static void

==== //depot/projects/trustedbsd/mac/sys/security/mac_none/mac_none.c#30 (text+ko) ====

@@ -305,11 +305,12 @@
 
 }
 
-static void
+static int
 mac_none_update_vnode_from_externalized(struct vnode *vp,
     struct label *vnodelabel, struct mac *extmac)
 {
 
+	return (0);
 }
 
 static void

==== //depot/projects/trustedbsd/mac/sys/security/mac_test/mac_test.c#3 (text+ko) ====

@@ -498,11 +498,12 @@
 
 }
 
-static void
+static int
 mac_test_update_vnode_from_externalized(struct vnode *vp,
     struct label *vnodelabel, struct mac *extmac)
 {
 
+	return (0);
 }
 
 static void

==== //depot/projects/trustedbsd/mac/sys/sys/mac_policy.h#65 (text+ko) ====

@@ -130,7 +130,7 @@
 		    struct label *vnodelabel);
 	void	(*mpo_update_procfsvnode_from_subject)(struct vnode *vp,
 		    struct label *vnodelabel, struct ucred *cred);
-	void	(*mpo_update_vnode_from_externalized)(struct vnode *vp,
+	int	(*mpo_update_vnode_from_externalized)(struct vnode *vp,
 		    struct label *vnodelabel, struct mac *mac);
 	void	(*mpo_update_vnode_from_mount)(struct vnode *vp,
 		    struct label *vnodelabel, struct mount *mp,

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe p4-projects" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200206241444.g5OEiAm41914>