From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B87D18B00 for ; Mon, 9 Oct 2023 13:09:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="VaNf6SEv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 412FFC433C8; Mon, 9 Oct 2023 13:09:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1696856960; bh=AhAKsyZXCfHh6x2zu6J8fzzO8738qSBYnoWkXQUUxt0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VaNf6SEv8I7eKTubbUBMd0HXVRj/iUvqo0Yop1awyAGVkTNGH0FUw1gUyttkMSU+P MHR4MWkQAqRF5Gc8+HuD8o5JKU6TUg8L0O1p+5mYiDhi8hkPvUkdh7mbHBr6MOvl5c AejTwLuhrN4gRqT74JSLafTSYTXJlHexkQjl9BB4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Anand Jain , Qu Wenruo , David Sterba Subject: [PATCH 6.5 049/163] btrfs: reject unknown mount options early Date: Mon, 9 Oct 2023 15:00:13 +0200 Message-ID: <20231009130125.385480581@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231009130124.021290599@linuxfoundation.org> References: <20231009130124.021290599@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.5-stable review patch. If anyone has any objections, please let me know. ------------------ From: Qu Wenruo commit 5f521494cc73520ffac18ede0758883b9aedd018 upstream. [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 CC: stable@vger.kernel.org # 4.14+ Signed-off-by: Qu Wenruo Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/super.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -948,6 +948,10 @@ static int btrfs_parse_subvol_options(co *subvol_objectid = subvolid; break; + case Opt_err: + btrfs_err(NULL, "unrecognized mount option '%s'", p); + error = -EINVAL; + goto out; default: break; }