summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2008-12-08 12:29:30 +0000
committerkib <kib@FreeBSD.org>2008-12-08 12:29:30 +0000
commit8324189f5379874d1b4d2b6716eaa7c503bab043 (patch)
treebfe45dc070c9ef09cba7319bbb4ca4ea563cbe67
parent672c135fef76269014512e62d821125bbcb042f5 (diff)
downloadFreeBSD-src-8324189f5379874d1b4d2b6716eaa7c503bab043.zip
FreeBSD-src-8324189f5379874d1b4d2b6716eaa7c503bab043.tar.gz
Do drop vm map lock earlier in the sysctl_kern_proc_vmmap(), to avoid
locking a vnode while having vm map locked. Reported and tested by: pho MFC after: 1 week
-rw-r--r--sys/kern/kern_proc.c78
1 files changed, 40 insertions, 38 deletions
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index 0b6b6d5..9f42891 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -1412,13 +1412,32 @@ sysctl_kern_proc_ovmmap(SYSCTL_HANDLER_ARGS)
lobj = tobj;
}
+ kve->kve_start = (void*)entry->start;
+ kve->kve_end = (void*)entry->end;
+ kve->kve_offset = (off_t)entry->offset;
+
+ if (entry->protection & VM_PROT_READ)
+ kve->kve_protection |= KVME_PROT_READ;
+ if (entry->protection & VM_PROT_WRITE)
+ kve->kve_protection |= KVME_PROT_WRITE;
+ if (entry->protection & VM_PROT_EXECUTE)
+ kve->kve_protection |= KVME_PROT_EXEC;
+
+ if (entry->eflags & MAP_ENTRY_COW)
+ kve->kve_flags |= KVME_FLAG_COW;
+ if (entry->eflags & MAP_ENTRY_NEEDS_COPY)
+ kve->kve_flags |= KVME_FLAG_NEEDS_COPY;
+
+ last_timestamp = map->timestamp;
+ vm_map_unlock_read(map);
+
kve->kve_fileid = 0;
kve->kve_fsid = 0;
freepath = NULL;
fullpath = "";
if (lobj) {
vp = NULL;
- switch(lobj->type) {
+ switch (lobj->type) {
case OBJT_DEFAULT:
kve->kve_type = KVME_TYPE_DEFAULT;
break;
@@ -1468,28 +1487,10 @@ sysctl_kern_proc_ovmmap(SYSCTL_HANDLER_ARGS)
kve->kve_shadow_count = 0;
}
- kve->kve_start = (void*)entry->start;
- kve->kve_end = (void*)entry->end;
- kve->kve_offset = (off_t)entry->offset;
-
- if (entry->protection & VM_PROT_READ)
- kve->kve_protection |= KVME_PROT_READ;
- if (entry->protection & VM_PROT_WRITE)
- kve->kve_protection |= KVME_PROT_WRITE;
- if (entry->protection & VM_PROT_EXECUTE)
- kve->kve_protection |= KVME_PROT_EXEC;
-
- if (entry->eflags & MAP_ENTRY_COW)
- kve->kve_flags |= KVME_FLAG_COW;
- if (entry->eflags & MAP_ENTRY_NEEDS_COPY)
- kve->kve_flags |= KVME_FLAG_NEEDS_COPY;
-
strlcpy(kve->kve_path, fullpath, sizeof(kve->kve_path));
if (freepath != NULL)
free(freepath, M_TEMP);
- last_timestamp = map->timestamp;
- vm_map_unlock_read(map);
error = SYSCTL_OUT(req, kve, sizeof(*kve));
vm_map_lock_read(map);
if (error)
@@ -1577,13 +1578,32 @@ sysctl_kern_proc_vmmap(SYSCTL_HANDLER_ARGS)
lobj = tobj;
}
+ kve->kve_start = entry->start;
+ kve->kve_end = entry->end;
+ kve->kve_offset = entry->offset;
+
+ if (entry->protection & VM_PROT_READ)
+ kve->kve_protection |= KVME_PROT_READ;
+ if (entry->protection & VM_PROT_WRITE)
+ kve->kve_protection |= KVME_PROT_WRITE;
+ if (entry->protection & VM_PROT_EXECUTE)
+ kve->kve_protection |= KVME_PROT_EXEC;
+
+ if (entry->eflags & MAP_ENTRY_COW)
+ kve->kve_flags |= KVME_FLAG_COW;
+ if (entry->eflags & MAP_ENTRY_NEEDS_COPY)
+ kve->kve_flags |= KVME_FLAG_NEEDS_COPY;
+
+ last_timestamp = map->timestamp;
+ vm_map_unlock_read(map);
+
kve->kve_fileid = 0;
kve->kve_fsid = 0;
freepath = NULL;
fullpath = "";
if (lobj) {
vp = NULL;
- switch(lobj->type) {
+ switch (lobj->type) {
case OBJT_DEFAULT:
kve->kve_type = KVME_TYPE_DEFAULT;
break;
@@ -1633,28 +1653,10 @@ sysctl_kern_proc_vmmap(SYSCTL_HANDLER_ARGS)
kve->kve_shadow_count = 0;
}
- kve->kve_start = entry->start;
- kve->kve_end = entry->end;
- kve->kve_offset = entry->offset;
-
- if (entry->protection & VM_PROT_READ)
- kve->kve_protection |= KVME_PROT_READ;
- if (entry->protection & VM_PROT_WRITE)
- kve->kve_protection |= KVME_PROT_WRITE;
- if (entry->protection & VM_PROT_EXECUTE)
- kve->kve_protection |= KVME_PROT_EXEC;
-
- if (entry->eflags & MAP_ENTRY_COW)
- kve->kve_flags |= KVME_FLAG_COW;
- if (entry->eflags & MAP_ENTRY_NEEDS_COPY)
- kve->kve_flags |= KVME_FLAG_NEEDS_COPY;
-
strlcpy(kve->kve_path, fullpath, sizeof(kve->kve_path));
if (freepath != NULL)
free(freepath, M_TEMP);
- last_timestamp = map->timestamp;
- vm_map_unlock_read(map);
/* Pack record size down */
kve->kve_structsize = offsetof(struct kinfo_vmentry, kve_path) +
strlen(kve->kve_path) + 1;
OpenPOWER on IntegriCloud