Re: [PATCH] btrfs: refuse to remount read-write with unsupported compat-ro features

From: Chung-Chiang Cheng
Date: Mon Dec 05 2022 - 21:42:21 EST


On Mon, Dec 5, 2022 at 6:45 PM Filipe Manana <fdmanana@xxxxxxxxxx> wrote:
>
> 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.
>

Wow. I did not notice this commit doing the same job by Qu. But I have
tested the latest linux-6.1 rc-7, and it's still able to mount a unsupported
comat-ro btrfs as read-write via remount.

It's caused by the follow-up commit d7f67ac9a928 ("btrfs: relax
block-group-tree feature dependency checks"). This commit checks read-
only with the current superblock, which will always pass in the situation
remounting from read-only to read-write. It seems `btrfs_check_features()`
cannot cover this scenario.

if (compat_ro_unsupp && !sb_rdonly(sb)) {
^^^^^^^^^^^^^^

Thanks,
C.C.Cheng