lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJfpegtK=dh0yNdvxSC8YF6vOYqGPM5EOWny07jYDdFc0qfhTQ@mail.gmail.com>
Date:   Mon, 24 Jul 2023 16:43:06 +0200
From:   Miklos Szeredi <miklos@...redi.hu>
To:     Andrea Righi <andrea.righi@...onical.com>
Cc:     Amir Goldstein <amir73il@...il.com>, linux-unionfs@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 3/3] ovl: validate superblock in OVL_FS()

On Sun, 21 May 2023 at 10:28, Andrea Righi <andrea.righi@...onical.com> wrote:
>
> 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@...il.com>
> Signed-off-by: Andrea Righi <andrea.righi@...onical.com>
> ---
>  fs/overlayfs/ovl_entry.h | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/fs/overlayfs/ovl_entry.h b/fs/overlayfs/ovl_entry.h
> index b32c38fdf3c7..e156649d9c71 100644
> --- a/fs/overlayfs/ovl_entry.h
> +++ b/fs/overlayfs/ovl_entry.h
> @@ -97,8 +97,20 @@ static inline struct mnt_idmap *ovl_upper_mnt_idmap(struct ovl_fs *ofs)
>
>  extern struct file_system_type ovl_fs_type;
>
> +static inline bool is_ovl_fs_sb(struct super_block *sb)
> +{
> +       return sb->s_type == &ovl_fs_type;
> +}
> +
> +#ifdef CONFIG_OVERLAY_FS_DEBUG
> +#define OVL_VALIDATE_SB(__sb)  WARN_ON_ONCE(!is_ovl_fs_sb(__sb))
> +#else
> +#define OVL_VALIDATE_SB(__sb)
> +#endif
> +
>  static inline struct ovl_fs *OVL_FS(struct super_block *sb)
>  {
> +       OVL_VALIDATE_SB(sb);

This could be written simply and naturally:

    if (IS_ENABLED(CONFIG_OVERLAY_FS_DEBUG))
         WARN_ON_ONCE(sb->s_type != &ovl_fs_type)

Thanks,
Miklos

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ