summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_proc.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2008-11-04 19:04:01 +0000
committerjhb <jhb@FreeBSD.org>2008-11-04 19:04:01 +0000
commit6c6f8c89e867271ab3baf15171419147ba85e088 (patch)
treeb47a8cae4ebd0444298548735180256fabe8a0d6 /sys/kern/kern_proc.c
parent9f264a6a75c77b629a7483254b17b870d9d292a8 (diff)
downloadFreeBSD-src-6c6f8c89e867271ab3baf15171419147ba85e088.zip
FreeBSD-src-6c6f8c89e867271ab3baf15171419147ba85e088.tar.gz
Remove unnecessary locking around vn_fullpath(). The vnode lock for the
vnode in question does not need to be held. All the data structures used during the name lookup are protected by the global name cache lock. Instead, the caller merely needs to ensure a reference is held on the vnode (such as vhold()) to keep it from being freed. In the case of procfs' <pid>/file entry, grab the process lock while we gain a new reference (via vhold()) on p_textvp to fully close races with execve(2). For the kern.proc.vmmap sysctl handler, use a shared vnode lock around the call to VOP_GETATTR() rather than an exclusive lock. MFC after: 1 month
Diffstat (limited to 'sys/kern/kern_proc.c')
-rw-r--r--sys/kern/kern_proc.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index aa48bd5..f8f639c 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -1440,11 +1440,11 @@ sysctl_kern_proc_vmmap(SYSCTL_HANDLER_ARGS)
kve->kve_shadow_count = obj->shadow_count;
VM_OBJECT_UNLOCK(obj);
if (vp != NULL) {
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
vn_fullpath(curthread, vp, &fullpath,
&freepath);
cred = curthread->td_ucred;
+ vfslocked = VFS_LOCK_GIANT(vp->v_mount);
+ vn_lock(vp, LK_SHARED | LK_RETRY);
if (VOP_GETATTR(vp, &va, cred) == 0) {
kve->kve_fileid = va.va_fileid;
kve->kve_fsid = va.va_fsid;
OpenPOWER on IntegriCloud