Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Jan 2010 19:15:12 GMT
From:      Jonathan Anderson <jona@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 173919 for review
Message-ID:  <201001291915.o0TJFClT091339@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/chv.cgi?CH=173919

Change 173919 by jona@jona-capsicum-kent64 on 2010/01/29 19:14:24

	Enable libcapsicum_fdlist stuff, since the mmap panic is gone

Affected files ...

.. //depot/projects/trustedbsd/capabilities/src/lib/libcapsicum/libcapsicum_fdlist.c#4 edit
.. //depot/projects/trustedbsd/capabilities/src/lib/libcapsicum/libcapsicum_host.c#4 edit

Differences ...

==== //depot/projects/trustedbsd/capabilities/src/lib/libcapsicum/libcapsicum_fdlist.c#4 (text+ko) ====

@@ -30,7 +30,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $P4: //depot/projects/trustedbsd/capabilities/src/lib/libcapsicum/libcapsicum_fdlist.c#3 $
+ * $P4: //depot/projects/trustedbsd/capabilities/src/lib/libcapsicum/libcapsicum_fdlist.c#4 $
  */
 
 #include <sys/mman.h>
@@ -42,6 +42,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 
 #include "libcapsicum_sandbox_api.h"
 
@@ -96,7 +97,6 @@
 	if (global_fdlist == NULL) {
 
 		char *env = getenv(LIBCAPABILITY_SANDBOX_FDLIST);
-		printf("%s: %s\n", LIBCAPABILITY_SANDBOX_FDLIST, env);
 
 		if ((env != NULL) && (strnlen(env, 8) < 7)) {
 
@@ -111,20 +111,13 @@
 			if (fd < 0)
 				return NULL;
 
-			printf("testing FD %i...", fd); fflush(stdout);
 			struct stat stats;
 			if (fstat(fd, &stats) < 0)
 				return NULL;
 
-			printf(" done. Size: %lu\n", stats.st_size);
-
-			printf("mapping FD %i... ", fd); fflush(stdout);
-			/*
 			global_fdlist = mmap(NULL, stats.st_size,
 			                     PROT_READ | PROT_WRITE,
-			                     MAP_NOSYNC | MAP_PRIVATE, fd, 0);
-			*/
-			printf(" done.\n");
+			                     MAP_NOSYNC | MAP_SHARED, fd, 0);
 		}
 	}
 
@@ -166,9 +159,12 @@
 	LOCK(orig);
 
 	int size = lc_fdlist_size(orig);
+	struct lc_fdlist *copy = NULL;
 
-	struct lc_fdlist *copy = malloc(size);
-	if (copy == NULL) return (NULL);
+	if (size > 0) {
+		copy = malloc(size);
+		if (copy != NULL) memcpy(copy, orig, size);
+	}
 
 	UNLOCK(orig);
 

==== //depot/projects/trustedbsd/capabilities/src/lib/libcapsicum/libcapsicum_host.c#4 (text+ko) ====

@@ -30,7 +30,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $P4: //depot/projects/trustedbsd/capabilities/src/lib/libcapsicum/libcapsicum_host.c#3 $
+ * $P4: //depot/projects/trustedbsd/capabilities/src/lib/libcapsicum/libcapsicum_host.c#4 $
  */
 
 #include <sys/param.h>
@@ -153,7 +153,7 @@
 	int *fd_array, fdcount;
 	struct sbuf *sbufp;
 	int shmfd, fdlistsize;
-	/*void *shm;*/
+	void *shm;
 	char fdliststr[8];
 	u_int i;
 
@@ -166,11 +166,7 @@
 	if (ftruncate(shmfd, fdlistsize) < 0) return;
 
 
-	printf("%dB of memory to mmap\n", fdlistsize);
-
-
 	/* map it and copy the list */
-	/*
 	shm = mmap(NULL, fdlistsize, PROT_READ | PROT_WRITE,
 	           MAP_NOSYNC | MAP_SHARED, shmfd, 0);
 
@@ -178,8 +174,6 @@
 	memcpy(shm, fds, fdlistsize);
 
 	if (munmap(shm, fdlistsize)) return;
-	*/
-
 
 
 



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