When a process attaches to a jail with a different root directory, file
descriptors opened before the attach retain access to files outside the
new
jail. Without UF_RESOLVE_BENEATH, these descriptors can be reopened via
fdescfs nodup or openat(O_EMPTY_PATH) to escalate access rights to them.
For example, a shared library opened read-only for linking against
inside the jail could be reopened as writable by the jailed process.
Set UF_RESOLVE_BENEATH on all open file descriptors in do_jail_attach()
when the jail root differs from the previous prison's root. This
restricts subsequent lookups and reopens to the access rights granted by
the file descriptors instead of allowing the jailed process to apply
its ambient authority inside its jail to files outside of it.