From 9719da13e74fefffb3f4a298dd63dae2ebd1bee3 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Fri, 12 Sep 2008 09:53:29 +0000 Subject: When doing rfork(0), i.e. separating curproc VM from any other user of the same vmspace, decrement the reference count of the shared LDT instead of a newly-made copy. Code factually removed LDT from the process that did rfork(0). Introduce user_ldt_deref() function that does decrement of refcount for the struct proc_ldt, and call it in the rfork(0) case on the shared LDT. Reviewed by: jhb MFC after: 1 week --- sys/i386/i386/sys_machdep.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'sys/i386/i386/sys_machdep.c') diff --git a/sys/i386/i386/sys_machdep.c b/sys/i386/i386/sys_machdep.c index f6aca9cd7497..7619db7c22da 100644 --- a/sys/i386/i386/sys_machdep.c +++ b/sys/i386/i386/sys_machdep.c @@ -526,6 +526,14 @@ user_ldt_free(struct thread *td) } mdp->md_ldt = NULL; + user_ldt_deref(pldt); +} + +void +user_ldt_deref(struct proc_ldt *pldt) +{ + + mtx_assert(&dt_lock, MA_OWNED); if (--pldt->ldt_refcnt == 0) { mtx_unlock_spin(&dt_lock); kmem_free(kernel_map, (vm_offset_t)pldt->ldt_base, -- cgit v1.2.3