Fix a race condition in socow_setup(): The page must be wired before

sf_buf_alloc() is called, as sf_buf_alloc() may sleep.  If it does sleep,
the page might be reclaimed before wiring occurs.

Reported by: alc
This commit is contained in:
Andrew Gallatin 2003-03-18 18:27:33 +00:00
parent cb3733b78d
commit daa949b66e

View File

@ -129,10 +129,6 @@ socow_setup(struct mbuf *m0, struct uio *uio)
}
pp = PHYS_TO_VM_PAGE(pa);
sf = sf_buf_alloc();
sf->m = pp;
pmap_qenter(sf->kva, &pp, 1);
/*
* set up COW
*/
@ -145,6 +141,13 @@ socow_setup(struct mbuf *m0, struct uio *uio)
vm_page_wire(pp);
vm_page_unlock_queues();
/*
* Allocate an sf buf
*/
sf = sf_buf_alloc();
sf->m = pp;
pmap_qenter(sf->kva, &pp, 1);
/*
* attach to mbuf
*/