From 64042a76b6bf7e6b13ddca3c9f79e07bca3b3533 Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Tue, 9 Nov 2004 22:21:10 +0000 Subject: [PATCH] Refuse attempts to mount root filesystem --- sys/fs/nullfs/null_vfsops.c | 2 ++ sys/fs/nwfs/nwfs_vfsops.c | 2 ++ sys/fs/portalfs/portal_vfsops.c | 2 +- sys/fs/smbfs/smbfs_vfsops.c | 5 ++--- sys/fs/umapfs/umap_vfsops.c | 2 +- sys/fs/unionfs/union_vfsops.c | 2 ++ sys/nfs4client/nfs4_vfsops.c | 2 +- 7 files changed, 11 insertions(+), 6 deletions(-) diff --git a/sys/fs/nullfs/null_vfsops.c b/sys/fs/nullfs/null_vfsops.c index ea49163bfcd0..d834d0431ac5 100644 --- a/sys/fs/nullfs/null_vfsops.c +++ b/sys/fs/nullfs/null_vfsops.c @@ -85,6 +85,8 @@ nullfs_mount(struct mount *mp, struct thread *td) NULLFSDEBUG("nullfs_mount(mp = %p)\n", (void *)mp); + if (mp->mnt_flag & MNT_ROOTFS) + return (EOPNOTSUPP); /* * Update is a no-op */ diff --git a/sys/fs/nwfs/nwfs_vfsops.c b/sys/fs/nwfs/nwfs_vfsops.c index 290004812aeb..5d807ab67882 100644 --- a/sys/fs/nwfs/nwfs_vfsops.c +++ b/sys/fs/nwfs/nwfs_vfsops.c @@ -147,6 +147,8 @@ static int nwfs_omount(struct mount *mp, char *path, caddr_t data, struct vnode *vp; char *pc,*pe; + if (mp->mnt_flag & MNT_ROOTFS) + return (EOPNOTSUPP); if (data == NULL) { nwfs_printf("missing data argument\n"); return 1; diff --git a/sys/fs/portalfs/portal_vfsops.c b/sys/fs/portalfs/portal_vfsops.c index dea2d397ad24..5ff1138068dc 100644 --- a/sys/fs/portalfs/portal_vfsops.c +++ b/sys/fs/portalfs/portal_vfsops.c @@ -85,7 +85,7 @@ portal_omount(mp, path, data, td) /* * Update is a no-op */ - if (mp->mnt_flag & MNT_UPDATE) + if (mp->mnt_flag & (MNT_UPDATE | MNT_ROOTFS)) return (EOPNOTSUPP); error = copyin(data, (caddr_t) &args, sizeof(struct portal_args)); diff --git a/sys/fs/smbfs/smbfs_vfsops.c b/sys/fs/smbfs/smbfs_vfsops.c index d8d90e407f7b..e841f912e9c1 100644 --- a/sys/fs/smbfs/smbfs_vfsops.c +++ b/sys/fs/smbfs/smbfs_vfsops.c @@ -122,10 +122,9 @@ smbfs_omount(struct mount *mp, char *path, caddr_t data, struct thread *td) printf("missing data argument\n"); return EINVAL; } - if (mp->mnt_flag & MNT_UPDATE) { - printf("MNT_UPDATE not implemented"); + if (mp->mnt_flag & (MNT_UPDATE | MNT_ROOTFS)) return EOPNOTSUPP; - } + error = copyin(data, (caddr_t)&args, sizeof(struct smbfs_args)); if (error) return error; diff --git a/sys/fs/umapfs/umap_vfsops.c b/sys/fs/umapfs/umap_vfsops.c index c9da7f7d2108..1417429fa809 100644 --- a/sys/fs/umapfs/umap_vfsops.c +++ b/sys/fs/umapfs/umap_vfsops.c @@ -99,7 +99,7 @@ umapfs_omount(mp, path, data, ndp, td) /* * Update is a no-op */ - if (mp->mnt_flag & MNT_UPDATE) { + if (mp->mnt_flag & (MNT_UPDATE | MNT_ROOTFS)) { return (EOPNOTSUPP); /* return (VFS_MOUNT(MOUNTTOUMAPMOUNT(mp)->umapm_vfs, path, data, ndp, td));*/ } diff --git a/sys/fs/unionfs/union_vfsops.c b/sys/fs/unionfs/union_vfsops.c index bf3fcfaaeeae..7383c0cd93b8 100644 --- a/sys/fs/unionfs/union_vfsops.c +++ b/sys/fs/unionfs/union_vfsops.c @@ -89,6 +89,8 @@ union_mount(mp, td) */ mp->mnt_flag |= MNT_NOCLUSTERW; + if (mp->mnt_flag & MNT_ROOTFS) + return (EOPNOTSUPP); /* * Update is a no-op */ diff --git a/sys/nfs4client/nfs4_vfsops.c b/sys/nfs4client/nfs4_vfsops.c index 6732c8c44785..24ba1af15b3a 100644 --- a/sys/nfs4client/nfs4_vfsops.c +++ b/sys/nfs4client/nfs4_vfsops.c @@ -393,7 +393,7 @@ nfs_omount(struct mount *mp, char *path, caddr_t data, struct thread *td) char hst[MNAMELEN]; size_t len; - if (path == NULL) { + if (mp->mnt_flag & MNT_ROOTFS) { printf("NFSv4: nfs_mountroot not supported\n"); return EINVAL; }