From: Andrea Righi Date: Sun, 21 May 2023 08:28:13 +0000 (+0200) Subject: ovl: validate superblock in OVL_FS() X-Git-Tag: v6.6-rc1~140^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=adcd459ff805ce5e11956cfa1e9aa85471b6ae8d;p=thirdparty%2Fkernel%2Fstable.git 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 Signed-off-by: Andrea Righi Signed-off-by: Amir Goldstein --- diff --git a/fs/overlayfs/ovl_entry.h b/fs/overlayfs/ovl_entry.h index edb457544b5f6..e9539f98e86a4 100644 --- a/fs/overlayfs/ovl_entry.h +++ b/fs/overlayfs/ovl_entry.h @@ -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; }