mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-28 04:45:43 +01:00
namespace: don't reconfigure internal superblocks via remount and umount
Commit02587a4af8("fs: refuse fspick() on internal superblocks") blocked fspick() on SB_NOUSER superblocks. But that's not the only way to reconfigure_super(). mount(MS_REMOUNT) and umount() of the caller's root without MNT_DETACH. The root of an empty mount namespace is a nullfs mount and all mount namespaces share that superblock: nullfs: fspick: FAIL errno=22 (Invalid argument) nullfs: mount(MS_REMOUNT|MS_RDONLY): ok(0) nullfs after remount: statfs(/): magic=0x4e554c4c flags=0x21 RDONLY nullfs: umount2("/", 0): ok(0) Refuse both like fspick() does. Only root in the initial user namespace can do this and nullfs is empty and immutable so the flags don't buy anything. But they show up in statfs() for the root of every mount namespace on the host. Fixes:9d4e752a24("namespace: allow creating empty mount namespaces") Cc: [email protected] # v7.1+ Link: https://patch.msgid.link/[email protected] Signed-off-by: Christian Brauner (Amutable) <[email protected]>
This commit is contained in:
2 files changed
+4
-3
No files matched your search
@@ -315,6 +315,10 @@ struct fs_context *fs_context_for_reconfigure(struct dentry *dentry,
|
||||
unsigned int sb_flags,
|
||||
unsigned int sb_flags_mask)
|
||||
{
|
||||
/* kernel-internal superblocks are nobody's to reconfigure */
|
||||
if (dentry->d_sb->s_flags & SB_NOUSER)
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
return alloc_fs_context(dentry->d_sb->s_type, dentry, sb_flags,
|
||||
sb_flags_mask, FS_CONTEXT_FOR_RECONFIGURE);
|
||||
}
|
||||
|
||||
@@ -190,9 +190,6 @@ SYSCALL_DEFINE3(fspick, int, dfd, const char __user *, path, unsigned int, flags
|
||||
ret = -EINVAL;
|
||||
if (target.mnt->mnt_root != target.dentry)
|
||||
goto err_path;
|
||||
/* kernel-internal superblocks are nobody's to reconfigure */
|
||||
if (target.dentry->d_sb->s_flags & SB_NOUSER)
|
||||
goto err_path;
|
||||
|
||||
fc = fs_context_for_reconfigure(target.dentry, 0, 0);
|
||||
if (IS_ERR(fc)) {
|
||||
|
||||
Reference in new issue
Block a user