devtmpfs regression fix: reconfigure on each mount
authorNeilBrown <neilb@suse.de>
Sun, 16 Jan 2022 22:07:26 +0000 (09:07 +1100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 20 Jan 2022 08:19:17 +0000 (09:19 +0100)
commit a6097180d884ddab769fb25588ea8598589c218c upstream.

Prior to Linux v5.4 devtmpfs used mount_single() which treats the given
mount options as "remount" options, so it updates the configuration of
the single super_block on each mount.

Since that was changed, the mount options used for devtmpfs are ignored.
This is a regression which affect systemd - which mounts devtmpfs with
"-o mode=755,size=4m,nr_inodes=1m".

This patch restores the "remount" effect by calling reconfigure_single()

Fixes: d401727ea0d7 ("devtmpfs: don't mix {ramfs,shmem}_fill_super() with mount_single()")
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/devtmpfs.c
fs/super.c
include/linux/fs_context.h

index 30d0523014e0d49e0ac6e16880a7bb08ecfbef27..5e9b00711357b0a93e2e77f5a08afac44e2c1005 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/kthread.h>
+#include <linux/fs_context.h>
 #include <uapi/linux/mount.h>
 #include "base.h"
 
@@ -62,8 +63,15 @@ static struct dentry *public_dev_mount(struct file_system_type *fs_type, int fla
                      const char *dev_name, void *data)
 {
        struct super_block *s = mnt->mnt_sb;
+       int err;
+
        atomic_inc(&s->s_active);
        down_write(&s->s_umount);
+       err = reconfigure_single(s, flags, data);
+       if (err < 0) {
+               deactivate_locked_super(s);
+               return ERR_PTR(err);
+       }
        return dget(s->s_root);
 }
 
index 877532baf513dd44963a11d6dae6f25950fd22f1..b289356f302fc864e78f37198ecc4a77a50c2df9 100644 (file)
@@ -1470,8 +1470,8 @@ struct dentry *mount_nodev(struct file_system_type *fs_type,
 }
 EXPORT_SYMBOL(mount_nodev);
 
-static int reconfigure_single(struct super_block *s,
-                             int flags, void *data)
+int reconfigure_single(struct super_block *s,
+                      int flags, void *data)
 {
        struct fs_context *fc;
        int ret;
index ba8a58754340d5c9da9c07734b6d75154fd87a1d..ebcb91a57e865aa5f84236dd4af7dc2f4f9bffa4 100644 (file)
@@ -135,6 +135,8 @@ extern int generic_parse_monolithic(struct fs_context *fc, void *data);
 extern int vfs_get_tree(struct fs_context *fc);
 extern void put_fs_context(struct fs_context *fc);
 extern void fc_drop_locked(struct fs_context *fc);
+int reconfigure_single(struct super_block *s,
+                      int flags, void *data);
 
 /*
  * sget() wrappers to be called from the ->get_tree() op.