Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107347730
D47992.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D47992.diff
View Options
diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c
--- a/sys/kern/kern_jail.c
+++ b/sys/kern/kern_jail.c
@@ -1687,9 +1687,18 @@
sizeof(pr->pr_osrelease));
#ifdef VIMAGE
- /* Allocate a new vnet if specified. */
- pr->pr_vnet = (pr_flags & PR_VNET)
- ? vnet_alloc() : ppr->pr_vnet;
+ /*
+ * Allocate a new vnet if specified.
+ *
+ * Set PR_VNET now if so, so that the vnet is disposed of
+ * properly when the jail is destroyed.
+ */
+ if (pr_flags & PR_VNET) {
+ pr->pr_flags |= PR_VNET;
+ pr->pr_vnet = vnet_alloc();
+ } else {
+ pr->pr_vnet = ppr->pr_vnet;
+ }
#endif
/*
* Allocate a dedicated cpuset for each jail.
@@ -3207,9 +3216,12 @@
* Removing a prison frees references
* from its parent.
*/
+ ppr = pr->pr_parent;
+ pr->pr_parent = NULL;
mtx_unlock(&pr->pr_mtx);
+
+ pr = ppr;
flags &= ~PD_LOCKED;
- pr = pr->pr_parent;
flags |= PD_DEREF | PD_DEUREF;
continue;
}
@@ -3236,7 +3248,7 @@
*/
TAILQ_FOREACH_SAFE(rpr, &freeprison, pr_list, tpr) {
#ifdef VIMAGE
- if (rpr->pr_vnet != rpr->pr_parent->pr_vnet)
+ if (rpr->pr_flags & PR_VNET)
vnet_destroy(rpr->pr_vnet);
#endif
if (rpr->pr_root != NULL)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 13, 8:29 PM (19 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15496327
Default Alt Text
D47992.diff (1 KB)
Attached To
Mode
D47992: jail: Avoid a use-after-free when destroying jails
Attached
Detach File
Event Timeline
Log In to Comment