Attaching to a jail changes its root directory and its process credentials. These operations both require unlocking the jail, and also need allprison_lock unlocked. That means that if two threads are trying to attach to different jails at the same time, it's possible for the process to end up with one jail's root directory but the other jail's credentials.
Solve this by forcing the process into single-threaded mode during the do_jail_attach operation. Since the problem is only intra-process, it's not necessary to try adding a new lock that would be higher in the order than the current vnode and process locks.