diff options
Diffstat (limited to 'fs/namespace.c')
-rw-r--r-- | fs/namespace.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/fs/namespace.c b/fs/namespace.c index 4fb1691b4355..783004af5707 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
@@ -2409,8 +2409,10 @@ static int do_new_mount(struct path *path, const char *fstype, int flags, | |||
2409 | mnt_flags |= MNT_NODEV | MNT_LOCK_NODEV; | 2409 | mnt_flags |= MNT_NODEV | MNT_LOCK_NODEV; |
2410 | } | 2410 | } |
2411 | if (type->fs_flags & FS_USERNS_VISIBLE) { | 2411 | if (type->fs_flags & FS_USERNS_VISIBLE) { |
2412 | if (!fs_fully_visible(type, &mnt_flags)) | 2412 | if (!fs_fully_visible(type, &mnt_flags)) { |
2413 | put_filesystem(type); | ||
2413 | return -EPERM; | 2414 | return -EPERM; |
2415 | } | ||
2414 | } | 2416 | } |
2415 | } | 2417 | } |
2416 | 2418 | ||
@@ -3245,6 +3247,10 @@ static bool fs_fully_visible(struct file_system_type *type, int *new_mnt_flags) | |||
3245 | if (mnt->mnt.mnt_sb->s_iflags & SB_I_NOEXEC) | 3247 | if (mnt->mnt.mnt_sb->s_iflags & SB_I_NOEXEC) |
3246 | mnt_flags &= ~(MNT_LOCK_NOSUID | MNT_LOCK_NOEXEC); | 3248 | mnt_flags &= ~(MNT_LOCK_NOSUID | MNT_LOCK_NOEXEC); |
3247 | 3249 | ||
3250 | /* Don't miss readonly hidden in the superblock flags */ | ||
3251 | if (mnt->mnt.mnt_sb->s_flags & MS_RDONLY) | ||
3252 | mnt_flags |= MNT_LOCK_READONLY; | ||
3253 | |||
3248 | /* Verify the mount flags are equal to or more permissive | 3254 | /* Verify the mount flags are equal to or more permissive |
3249 | * than the proposed new mount. | 3255 | * than the proposed new mount. |
3250 | */ | 3256 | */ |
@@ -3271,7 +3277,7 @@ static bool fs_fully_visible(struct file_system_type *type, int *new_mnt_flags) | |||
3271 | list_for_each_entry(child, &mnt->mnt_mounts, mnt_child) { | 3277 | list_for_each_entry(child, &mnt->mnt_mounts, mnt_child) { |
3272 | struct inode *inode = child->mnt_mountpoint->d_inode; | 3278 | struct inode *inode = child->mnt_mountpoint->d_inode; |
3273 | /* Only worry about locked mounts */ | 3279 | /* Only worry about locked mounts */ |
3274 | if (!(mnt_flags & MNT_LOCKED)) | 3280 | if (!(child->mnt.mnt_flags & MNT_LOCKED)) |
3275 | continue; | 3281 | continue; |
3276 | /* Is the directory permanetly empty? */ | 3282 | /* Is the directory permanetly empty? */ |
3277 | if (!is_empty_dir_inode(inode)) | 3283 | if (!is_empty_dir_inode(inode)) |