When a file descriptor received over a unix socket from a different jail
has UF_RESOLVE_BENEATH set (via restrict_rights()), reopening it through
fdescfs mounted with the "nodup" option strips the flag. This happens
because the nodup path returns the underlying vnode directly, bypassing
the dupfdopen() mechanism which would've turned the reopen into a dup()
like operation. The resulting VOP_OPEN succeeds via the vnode's real
filesystem which doesn't know the flags the file was opened with.
Fix this by using td_dupfd as a side-channel to propagate the original
fd's flags from fdescfs to kern_openat(). During fdesc_lookup(), use
fget_cap() instead of fget() to retrieve the fd flags (and open file).
In fdesc_get_ino_alloc(), when nodup is active and UF_RESOLVE_BENEATH is
set, store the original file's f_flag in td_dupfd. In openatfp(),
check td_dupfd on the success path and force O_RESOLVE_BENEATH into
the flags before finstall_refed() installs the new fd.
This prevents laundering cross-jail file descriptors through fdescfs
to escape the RESOLVE_BENEATH confinement.
PR: 262179, 262180