[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAL3q7H5oet2P9XijTtzPo3joZWdoa3OuD9L-wK9nTEFya2PY8w@mail.gmail.com>
Date: Mon, 5 Dec 2022 10:44:23 +0000
From: Filipe Manana <fdmanana@...nel.org>
To: Chung-Chiang Cheng <cccheng@...ology.com>
Cc: clm@...com, josef@...icpanda.com, dsterba@...e.com,
linux-btrfs@...r.kernel.org, linux-kernel@...r.kernel.org,
shepjeng@...il.com, kernel@...heng.net,
Johnny Chang <johnnyc@...ology.com>
Subject: Re: [PATCH] btrfs: refuse to remount read-write with unsupported
compat-ro features
On Thu, Dec 1, 2022 at 5:07 PM Chung-Chiang Cheng <cccheng@...ology.com> wrote:
>
> btrfs with unsupported compat-ro features can only be mounted as
> read-only, but we can make it read-write indirectly through remount.
> Just add the missing check to refuse it.
>
> mount -o ro /dev/vdb /mnt
> mount -o remount,rw /mnt
>
> Reported-by: Johnny Chang <johnnyc@...ology.com>
> Signed-off-by: Chung-Chiang Cheng <cccheng@...ology.com>
> ---
> fs/btrfs/super.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> index 5942b9384088..45836a426499 100644
> --- a/fs/btrfs/super.c
> +++ b/fs/btrfs/super.c
> @@ -1991,6 +1991,8 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
> unsigned old_flags = sb->s_flags;
> unsigned long old_opts = fs_info->mount_opt;
> unsigned long old_compress_type = fs_info->compress_type;
> + u64 compat_ro = btrfs_super_compat_ro_flags(fs_info->super_copy);
> + u64 compat_ro_unsupp = compat_ro & ~BTRFS_FEATURE_COMPAT_RO_SUPP;
> u64 old_max_inline = fs_info->max_inline;
> u32 old_thread_pool_size = fs_info->thread_pool_size;
> u32 old_metadata_ratio = fs_info->metadata_ratio;
> @@ -2107,6 +2109,13 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
> if (ret)
> goto restore;
> } else {
> + if (compat_ro_unsupp) {
> + btrfs_err(fs_info,
> + "cannot remount read-write because of unknown compat_ro features (0x%llx)",
> + compat_ro);
> + ret = -EINVAL;
> + goto restore;
> + }
Wasn't this already done by the following commit?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=81d5d61454c365718655cfc87d8200c84e25d596
Thanks.
> if (BTRFS_FS_ERROR(fs_info)) {
> btrfs_err(fs_info,
> "Remounting read-write after error is not allowed");
> --
> 2.34.1
>
Powered by blists - more mailing lists