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.

Changing the new argument for vfs_export() to "int" and
moving the prototype for vfs_exjail_delete() to jail.h
were both necessary to allow libprocstat to build.

(cherry picked from commit 88175af8b75ea8850757cc9dca68b6d336b82675)

Details

Provenance
rmacklemAuthored on Feb 21 2023, 9:00 PM
Parents
rG8e0b31c791cf: Fix off-by-one error in fsck_ffs(8) chkrange() block-number check.
Branches
Unknown
Tags
Unknown