Skip to content

Commit adcd459

Browse files
Andrea Righiamir73il
authored andcommitted
ovl: validate superblock in OVL_FS()
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>
1 parent f01d088 commit adcd459

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/overlayfs/ovl_entry.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ extern struct file_system_type ovl_fs_type;
121121

122122
static inline struct ovl_fs *OVL_FS(struct super_block *sb)
123123
{
124+
if (IS_ENABLED(CONFIG_OVERLAY_FS_DEBUG))
125+
WARN_ON_ONCE(sb->s_type != &ovl_fs_type);
126+
124127
return (struct ovl_fs *)sb->s_fs_info;
125128
}
126129

0 commit comments

Comments
 (0)