Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 Oct 2009 11:42:24 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r197857 - in stable/7/sys: . contrib/pf kern
Message-ID:  <200910081142.n98BgOGp021906@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Thu Oct  8 11:42:24 2009
New Revision: 197857
URL: http://svn.freebsd.org/changeset/base/197857

Log:
  MFC r197662:
  Do not dereference vp->v_mount without holding vnode lock and checking
  that the vnode is not reclaimed.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/kern/uipc_syscalls.c

Modified: stable/7/sys/kern/uipc_syscalls.c
==============================================================================
--- stable/7/sys/kern/uipc_syscalls.c	Thu Oct  8 11:36:06 2009	(r197856)
+++ stable/7/sys/kern/uipc_syscalls.c	Thu Oct  8 11:42:24 2009	(r197857)
@@ -2076,9 +2076,11 @@ retry_space:
 				/*
 				 * Get the page from backing store.
 				 */
-				bsize = vp->v_mount->mnt_stat.f_iosize;
 				vfslocked = VFS_LOCK_GIANT(vp->v_mount);
-				vn_lock(vp, LK_SHARED | LK_RETRY, td);
+				error = vn_lock(vp, LK_SHARED, td);
+				if (error != 0)
+					goto after_read;
+				bsize = vp->v_mount->mnt_stat.f_iosize;
 
 				/*
 				 * XXXMAC: Because we don't have fp->f_cred
@@ -2091,6 +2093,7 @@ retry_space:
 				    IO_VMIO | ((MAXBSIZE / bsize) << IO_SEQSHIFT),
 				    td->td_ucred, NOCRED, &resid, td);
 				VOP_UNLOCK(vp, 0, td);
+			after_read:
 				VFS_UNLOCK_GIANT(vfslocked);
 				VM_OBJECT_LOCK(obj);
 				vm_page_io_finish(pg);



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