PERFORCE change 41616 for review

Robert Watson rwatson at FreeBSD.org
Fri Nov 7 04:43:40 GMT 2003


http://perforce.freebsd.org/chv.cgi?CH=41616

Change 41616 by rwatson at rwatson_paprika on 2003/11/06 20:43:25

	Whitespace, linewrap.

Affected files ...

.. //depot/projects/trustedbsd/mac/sys/kern/sysv_shm.c#15 edit

Differences ...

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

@@ -279,7 +279,10 @@
 	if (!jail_sysvipc_allowed && jailed(td->td_ucred))
 		return (ENOSYS);
 
-	/* Prevent thread from going any further if module is (being) unloaded */
+	/*
+	 * Prevent thread from going any further if module is (being)
+	 * unloaded.
+	 */
 	mtx_lock(&refcnt_mtx);
 	if (refcount < 0 ) {
 		mtx_unlock(&refcnt_mtx);
@@ -305,13 +308,17 @@
 		goto done2;
 	}
 #ifdef MAC
-	/* XXX It might be useful to move this into the shm_delete_mapping function */
+	/*
+	 * XXX: It might be useful to move this into the shm_delete_mapping
+	 * function
+	 */
 	struct shmid_kernel *shmsegptr;
 	shmsegptr = &shmsegs[IPCID_TO_IX(shmmap_s->shmid)];
-  if(( error = mac_check_ipc_shmdt(td->td_ucred, shmsegptr) )) { 
-    MPRINTF(("MAC Framework:  mac_check_ipc_shmdt access denied\n"));
-    goto done2;
-  }
+	if ((error = mac_check_ipc_shmdt(td->td_ucred, shmsegptr))) {
+		MPRINTF((
+    "MAC Framework:  mac_check_ipc_shmdt access denied\n"));
+		goto done2;
+	}
 #endif
 	error = shm_delete_mapping(p->p_vmspace, shmmap_s);
 done2:
@@ -355,7 +362,10 @@
 	if (!jail_sysvipc_allowed && jailed(td->td_ucred))
 		return (ENOSYS);
 
-	/* Prevent thread from going any further if module is (being) unloaded */
+	/*
+	 * Prevent thread from going any further if module is (being)
+	 * unloaded.
+	 */
 	mtx_lock(&refcnt_mtx);
 	if (refcount < 0 ) {
 		mtx_unlock(&refcnt_mtx);
@@ -383,10 +393,11 @@
 	if (error)
 		goto done2;
 #ifdef MAC
-  if(( error = mac_check_ipc_shmat(td->td_ucred, shmseg, shmflg) )) { 
-    MPRINTF(("MAC Framework:  mac_check_ipc_shmat access denied\n"));
-    goto done2;
-  }
+	if ((error = mac_check_ipc_shmat(td->td_ucred, shmseg, shmflg))) {
+	 	MPRINTF((
+    "MAC Framework:  mac_check_ipc_shmat access denied\n"));
+		goto done2;
+	}
 #endif
 	for (i = 0; i < shminfo.shmseg; i++) {
 		if (shmmap_s->shmid == -1)
@@ -492,7 +503,10 @@
 	if (!jail_sysvipc_allowed && jailed(td->td_ucred))
 		return (ENOSYS);
 
-	/* Prevent thread from going any further if module is (being) unloaded */
+	/*
+	 * Prevent thread from going any further if module is (being)
+	 * unloaded.
+	 */
 	mtx_lock(&refcnt_mtx);
 	if (refcount < 0 ) {
 		mtx_unlock(&refcnt_mtx);
@@ -513,10 +527,11 @@
 		if (error)
 			goto done2;
 #ifdef MAC
-  	if(( error = mac_check_ipc_shmctl(td->td_ucred, shmseg, uap->cmd) )) {
-    	MPRINTF(("MAC Framework:  mac_check_ipc_shmctl access denied\n"));
-    	goto done2;
-  	}
+  	if ((error = mac_check_ipc_shmctl(td->td_ucred, shmseg, uap->cmd))) {
+    		MPRINTF((
+    "MAC Framework:  mac_check_ipc_shmctl access denied\n"));
+		goto done2;
+	}
 #endif
 		outbuf.shm_perm = shmseg->u.shm_perm;
 		outbuf.shm_segsz = shmseg->u.shm_segsz;
@@ -573,7 +588,10 @@
 	if (!jail_sysvipc_allowed && jailed(td->td_ucred))
 		return (ENOSYS);
 
-	/* Prevent thread from going any further if module is (being) unloaded */
+	/*
+	 * Prevent thread from going any further if module is (being)
+	 * unloaded
+	 */
 	mtx_lock(&refcnt_mtx);
 	if (refcount < 0 ) {
 		mtx_unlock(&refcnt_mtx);
@@ -614,10 +632,11 @@
 		goto done2;
 	}
 #ifdef MAC
-  if(( error = mac_check_ipc_shmctl(td->td_ucred, shmseg, cmd) )) {
-  	MPRINTF(("MAC Framework:  mac_check_ipc_shmctl access denied\n"));
-  	goto done2;
-  }
+	if ((error = mac_check_ipc_shmctl(td->td_ucred, shmseg, cmd))) {
+		MPRINTF((
+    "MAC Framework:  mac_check_ipc_shmctl access denied\n"));
+		goto done2;
+	}
 #endif
 	switch (cmd) {
 	case SHM_STAT:
@@ -746,8 +765,9 @@
 		return (EEXIST);
 	error = ipcperm(td, &shmseg->u.shm_perm, mode);
 #ifdef MAC
-	if(( error = mac_check_ipc_shmget(td->td_ucred,shmseg,uap->shmflg) )) {
-		MPRINTF(("MAC Framework:  mac_check_ipc_shmget access denied\n"));
+	if ((error = mac_check_ipc_shmget(td->td_ucred,shmseg,uap->shmflg))) {
+		MPRINTF((
+    "MAC Framework:  mac_check_ipc_shmget access denied\n"));
 	}
 #endif
 	if (error)
@@ -828,7 +848,7 @@
 	shmseg->u.shm_lpid = shmseg->u.shm_nattch = 0;
 	shmseg->u.shm_atime = shmseg->u.shm_dtime = 0;
 #ifdef MAC
-  mac_create_ipc_shm(cred, shmseg);
+	mac_create_ipc_shm(cred, shmseg);
 #endif
 	shmseg->u.shm_ctime = time_second;
 	shm_committed += btoc(size);
@@ -859,7 +879,10 @@
 	if (!jail_sysvipc_allowed && jailed(td->td_ucred))
 		return (ENOSYS);
 
-	/* Prevent thread from going any further if module is (being) unloaded */
+	/*
+	 * Prevent thread from going any further if module is (being)
+	 * unloaded.
+	 */
 	mtx_lock(&refcnt_mtx);
 	if (refcount < 0 ) {
 		mtx_unlock(&refcnt_mtx);
@@ -949,7 +972,10 @@
 		vm->vm_shm = NULL;
 		for (i = 0, shm = base; i < shminfo.shmseg; i++, shm++) {
 			if (shm->shmid != -1)
-				/* XXX: Should the MAC framework enforce check here as well */
+				/*
+				 * XXX: Should the MAC framework enforce
+				 * check here as well.
+				 */
 				shm_delete_mapping(vm, shm);
 		}
 		free(base, M_SHM);
@@ -1015,14 +1041,14 @@
 	shmexit_hook = &shmexit_myhook;
 	shmfork_hook = &shmfork_myhook;
 	refcount = 0;
-	/* 
-	 * It is not permissible to pass the same mutex to mtx_init() multiple 
-	 * times without intervening calls to mtx_destroy().
-	 * Since we cannot destroy the refcnt_mtx during shmunload, we check if 
-	 * the mtx_init has ever been called. If so, we dont need to do mtx_init
-	 * as the mutex is already initialized.
+	/*
+	 * It is not permissible to pass the same mutex to mtx_init()
+	 * multiple times without intervening calls to mtx_destroy().  Since
+	 * we cannot destroy the refcnt_mtx during shmunload, we check if
+	 * the mtx_init has ever been called. If so, we dont need to do
+	 * mtx_init as the mutex is already initialized.
 	 */
-	if ( mtx_initialized(&refcnt_mtx) == 0 )
+	if (mtx_initialized(&refcnt_mtx) == 0)
 		mtx_init(&refcnt_mtx, "shmrefcnt", NULL, MTX_DEF);
 }
 
@@ -1031,11 +1057,11 @@
 {
 
 	/* 
-	 * Make sure that the shmunload maintains the consistency of the shmsegs
-	 * data structure. This assures that the unload doesn't take place if 
-	 * any thread is in any of the code-paths (tinkering with the data 
-	 * structures), and also that no thread can enter the code-paths once 
-	 * the module is unloaded. 
+	 * Make sure that the shmunload maintains the consistency of the
+	 * shmsegs data structure.  This assures that the unload doesn't
+	 * take place if any thread is in any of the code-paths (tinkering
+	 * with the data structures), and also that no thread can enter
+	 * the code-paths once the module is unloaded. 
 	 */
 	mtx_lock(&refcnt_mtx);
 	if ((refcount > 0) || (shm_nused > 0)) {
To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message



More information about the trustedbsd-cvs mailing list