]> git.ipfire.org Git - thirdparty/linux.git/commit
btrfs: reject unknown mount options early
authorQu Wenruo <wqu@suse.com>
Wed, 27 Sep 2023 01:13:15 +0000 (10:43 +0930)
committerDavid Sterba <dsterba@suse.com>
Tue, 3 Oct 2023 23:03:08 +0000 (01:03 +0200)
commit5f521494cc73520ffac18ede0758883b9aedd018
tree39e7f6d6744b119704af30b54c4d029e619c0d65
parent9147b9ded499d9853bdf0e9804b7eaa99c4429ed
btrfs: reject unknown mount options early

[BUG]
The following script would allow invalid mount options to be specified
(although such invalid options would just be ignored):

  # mkfs.btrfs -f $dev
  # mount $dev $mnt1 <<< Successful mount expected
  # mount $dev $mnt2 -o junk <<< Failed mount expected
  # echo $?
  0

[CAUSE]
For the 2nd mount, since the fs is already mounted, we won't go through
open_ctree() thus no btrfs_parse_options(), but only through
btrfs_parse_subvol_options().

However we do not treat unrecognized options from valid but irrelevant
options, thus those invalid options would just be ignored by
btrfs_parse_subvol_options().

[FIX]
Add the handling for Opt_err to handle invalid options and error out,
while still ignore other valid options inside btrfs_parse_subvol_options().

Reported-by: Anand Jain <anand.jain@oracle.com>
CC: stable@vger.kernel.org # 4.14+
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/super.c