HomeFreeBSD

vfs_export: Add mnt_exjail to control exports done in prisons

Description

vfs_export: Add mnt_exjail to control exports done in prisons

If there are multiple instances of mountd(8) (in different
prisons), there will be confusion if they manipulate the
exports of the same file system. This patch adds mnt_exjail
to "struct mount" so that the credentials (and, therefore,
the prison) that did the exports for that file system can
be recorded. If another prison has already exported the
file system, vfs_export() will fail with an error.
If mnt_exjail == NULL, the file system has not been exported.
mnt_exjail is checked by the NFS server, so that exports done
from within a different prison will not be used.

The patch also implements vfs_exjail_destroy(), which is
called from prison_cleanup() to release all the mnt_exjail
credential references, so that the prison can be removed.
Mainly to avoid doing a scan of the mountlist for the case
where there were no exports done from within the prison,
a count of how many file systems have been exported from
within the prison is kept in pr_exportcnt.

mnt_exjail replaces mnt_pad0 and should not change the size
of "struct mount" nor change the offsets of the other fields
in "struct mount". As such, it should be safe to MFC.

(cherry picked from commit 88175af8b75ea8850757cc9dca68b6d336b82675)

Details

Provenance
rmacklemAuthored on Feb 21 2023, 9:00 PM
Parents
rGaf8fd75b4593: ix(4): correct max MTU
Branches
Unknown
Tags
Unknown
Reverted By
rG3bd0519d7485: Revert "vfs_export: Add mnt_exjail to control exports done in prisons"