summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2012-12-10 22:39:39 +0000
committerJerry Jelinek <jerry.jelinek@joyent.com>2012-12-10 22:39:39 +0000
commit47e8e95219261e8522be82baf4670e68c5ce0f8c (patch)
tree892c5cc83dec6ac225a8af8de7779c1fc8fb0d23 /usr/src
parent33b3adb4cccf80561b80b2ce77b62d8574f4d4cf (diff)
downloadillumos-joyent-47e8e95219261e8522be82baf4670e68c5ce0f8c.tar.gz
OS-1756 task_join()/pr_lookup_procdir()/pr_szoneid() deadlock
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/uts/common/fs/proc/prcontrol.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/usr/src/uts/common/fs/proc/prcontrol.c b/usr/src/uts/common/fs/proc/prcontrol.c
index 53709139cc..dc95278c0b 100644
--- a/usr/src/uts/common/fs/proc/prcontrol.c
+++ b/usr/src/uts/common/fs/proc/prcontrol.c
@@ -2259,9 +2259,17 @@ pr_szoneid(proc_t *p, zoneid_t zoneid, cred_t *cr)
return (EPERM);
if (zoneid != GLOBAL_ZONEID && zoneid != p->p_zone->zone_id)
return (EINVAL);
- if ((zptr = zone_find_by_id(zoneid)) == NULL)
- return (EINVAL);
+ /*
+ * We cannot hold p_lock when we call zone_find_by_id since that can
+ * lead to a deadlock. zone_find_by_id() takes zonehash_lock.
+ * zone_enter() can hold the zonehash_lock and needs p_lock when it
+ * calls task_join.
+ */
mutex_exit(&p->p_lock);
+ if ((zptr = zone_find_by_id(zoneid)) == NULL) {
+ mutex_enter(&p->p_lock);
+ return (EINVAL);
+ }
mutex_enter(&p->p_crlock);
oldcred = p->p_cred;
crhold(oldcred);