Avoid sleeping while recording SEM_UNDO information
sys_semop(), by way of semundo_adjust() and semu_alloc(), could sleep in
pool_get(PR_WAITOK) after it had already applied the semaphore operations.
Another process can remove the set with IPC_RMID while we sleep; we then write
sempid and sem_otime through the freed semid_ds_kern and sem_base, and record
an undo entry for a set semundo_clear() has already swept, which panics
semexit() when the process exits.
This was introduced as a fallback in rev 1.14, after moving the
structures from a static array to a pool made the allocation able to
fail at all. semop(2) documents ENOSPC, so drop the fallback with the
extra complexity to work around the sleep.
semundo_adjust() must then stop freeing an emptied structure in the middle of
an operation: sys_semop()'s rollback can need it again, and re-creating it
there is allowed to fail, which is a panic. Keep it until done2. That also
takes a second sleeping pool_put() out of the done: region.
[7 lines not shown]