[SSI] openssi/kernel/ipc shm.c,1.29,1.30

Roger Tsang <[email protected]> Sun, 07 Mar 2010 06:00:30 +0000
Newsgroups gmane.linux.cluster.ssic.cvs
Message-ID <[email protected]>
Update of /cvsroot/ssic-linux/openssi/kernel/ipc
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv2051/ipc

Modified Files:
      Tag: OPENSSI-FC
	shm.c 
Log Message:
Fix null pointer dereference in ipc_shm_nodedown() if lost race with destroy.


Index: shm.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/ipc/shm.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- shm.c	7 Mar 2010 05:40:14 -0000	1.29
+++ shm.c	7 Mar 2010 06:00:28 -0000	1.30
@@ -1519,7 +1519,7 @@
 	struct shmid_kernel *shp;
 	struct vfsmount *mnt;
 	int id;
-	char sem_held = 0;
+	char sem_held;
 
 	icssvr_nodedown_svc_wait(node, cluster_ipc_svc);
 
@@ -1532,17 +1532,17 @@
 	/* Don't wait for shm_ids.sem since we may deadlock with
 	 * a SHM segment with SHM_LOCK_DEST flag.
 	 */
-	if (down_trylock(&ids->sem)) {
-		if ((id = ids->lock_dest_id) != -1) {
-			/* segment being destroyed by remote server */
-			shp = shm_lock(id);
-			if (shp && shp->shm_node == node &&
+	sem_held = !down_trylock(&ids->sem);
+	if (!sem_held && (id = ids->lock_dest_id) != -1) {
+		/* segment being destroyed by remote server */
+		shp = shm_lock(id);
+		if (shp) {
+			if (shp->shm_node == node &&
 			    (shp->shm_flags & SHM_LOCK_DEST))
 				sem_held = 1;
 			shm_unlock(shp);
 		}
-	} else
-		sem_held = 1;
+	}
 
  	for (id = 0; id <= ids->max_id; id++) {
 		shp = shm_lock(id);


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev