]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
ovl: validate superblock in OVL_FS()
authorAndrea Righi <andrea.righi@canonical.com>
Sun, 21 May 2023 08:28:13 +0000 (10:28 +0200)
committerAmir Goldstein <amir73il@gmail.com>
Sat, 12 Aug 2023 16:02:54 +0000 (19:02 +0300)
When CONFIG_OVERLAY_FS_DEBUG is enabled add an explicit check to make
sure that OVL_FS() is always used with a valid overlayfs superblock.
Otherwise trigger a WARN_ON_ONCE().

Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
fs/overlayfs/ovl_entry.h

index edb457544b5f63709038d17ea3acb9a2a0551607..e9539f98e86a4b29d0c54dc1859ea13d37cd46f2 100644 (file)
@@ -121,6 +121,9 @@ extern struct file_system_type ovl_fs_type;
 
 static inline struct ovl_fs *OVL_FS(struct super_block *sb)
 {
+       if (IS_ENABLED(CONFIG_OVERLAY_FS_DEBUG))
+               WARN_ON_ONCE(sb->s_type != &ovl_fs_type);
+
        return (struct ovl_fs *)sb->s_fs_info;
 }