aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2024-05-15 09:54:49 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2024-05-16 01:00:26 +0000
commit21ccdb4119afdfdfeaa80e9c8514171c65b35862 (patch)
treed682b6986536f24751125084f9d9a0836732e43e
parent5a061a38cdfa151315051a1ca1400bb32e39cde2 (diff)
downloadsrc-21ccdb4119afdfdfeaa80e9c8514171c65b35862.tar.gz
src-21ccdb4119afdfdfeaa80e9c8514171c65b35862.zip
vfs_domount_update(): postpone setting MNT_UNION until VFS_MOUNT() is done
The file system that handles updating the mount point might do lookups during the update, in which case it could find the flag MNT_UNION set on the mp while mount point is still not updated. In particular, the rootvp->v_mount->mnt_vnodecovered is not yet set. Delay setting MNT_UNION until the mount is performed. PR: 265311 Reported by: Robert Morris <rtm@lcs.mit.edu> Reviewed by: mckusick, olce Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D45208
-rw-r--r--sys/kern/vfs_mount.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c
index 4961eb332473..f5ff8d54fadd 100644
--- a/sys/kern/vfs_mount.c
+++ b/sys/kern/vfs_mount.c
@@ -1313,7 +1313,7 @@ vfs_domount_update(
void *bufp;
struct mount *mp;
int error, export_error, i, len, fsid_up_len;
- uint64_t flag;
+ uint64_t flag, mnt_union;
gid_t *grps;
fsid_t *fsid_up;
bool vfs_suser_failed;
@@ -1395,6 +1395,7 @@ vfs_domount_update(
vfs_deleteopt(*optlist, "fsid");
}
+ mnt_union = 0;
MNT_ILOCK(mp);
if ((mp->mnt_kern_flag & MNTK_UNMOUNT) != 0) {
MNT_IUNLOCK(mp);
@@ -1416,6 +1417,11 @@ vfs_domount_update(
mp->mnt_flag |= MNT_UPDATE;
} else {
mp->mnt_flag &= ~MNT_UPDATEMASK;
+ if ((mp->mnt_flag & MNT_UNION) == 0 &&
+ (fsflags & MNT_UNION) != 0) {
+ fsflags &= ~MNT_UNION;
+ mnt_union = MNT_UNION;
+ }
mp->mnt_flag |= fsflags & (MNT_RELOAD | MNT_FORCE | MNT_UPDATE |
MNT_SNAPSHOT | MNT_ROOTFS | MNT_UPDATEMASK | MNT_RDONLY);
if ((mp->mnt_flag & MNT_ASYNC) == 0)
@@ -1519,6 +1525,7 @@ vfs_domount_update(
if (error == 0) {
mp->mnt_flag &= ~(MNT_UPDATE | MNT_RELOAD | MNT_FORCE |
MNT_SNAPSHOT);
+ mp->mnt_flag |= mnt_union;
} else {
/*
* If we fail, restore old mount flags. MNT_QUOTA is special,