Building on the previous commit that preserves FD_RESOLVE_BENEATH across
fdescfs nodup reopens, also enforce that the new file descriptor does not
gain additional access rights over the original.
When td_dupfd carries the original fd's f_flag, check that the new
open's access mode (FREAD|FWRITE) is a subset of the original's.
If the new open requests rights not present in the original, fail with EACCES.
This matches the subset check that dupfdopen() performs for the non-nodup case.
Without this check, a file descriptor with FD_RESOLVE_BENEATH could be
reopened through an fdescfs mountpoint with the nodup option,
escalating access rights on the underlying vnode.
The previous behavior allowed a local privilege escalations across jails
since the access permissions on the file outside of the current jail would be
reevaluated against the jailed process's credentials even if the file
is not reachable by any absolute path from inside the jail
other than through fdescfs.