Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 56f6e554 authored by Johannes Kimmel's avatar Johannes Kimmel Committed by Greg Kroah-Hartman
Browse files

btrfs: correctly escape subvol in btrfs_show_options()



commit dc08c58696f8555e4a802f1f23c894a330d80ab7 upstream.

Currently, displaying the btrfs subvol mount option doesn't escape ','.
This makes parsing /proc/self/mounts and /proc/self/mountinfo
ambiguous for subvolume names that contain commas. The text after the
comma could be mistaken for another option (think "subvol=foo,ro", where
ro is actually part of the subvolumes name).

Replace the manual escape characters list with a call to
seq_show_option(). Thanks to Calvin Walton for suggesting this approach.

Fixes: c8d3fe02 ("Btrfs: show subvol= and subvolid= in /proc/mounts")
CC: stable@vger.kernel.org # 5.4+
Suggested-by: default avatarCalvin Walton <calvin.walton@kepstin.ca>
Signed-off-by: default avatarJohannes Kimmel <kernel@bareminimum.eu>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent beca6a8f
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -1380,8 +1380,7 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry)
	subvol_name = btrfs_get_subvol_name_from_objectid(info,
			BTRFS_I(d_inode(dentry))->root->root_key.objectid);
	if (!IS_ERR(subvol_name)) {
		seq_puts(seq, ",subvol=");
		seq_escape(seq, subvol_name, " \t\n\\");
		seq_show_option(seq, "subvol", subvol_name);
		kfree(subvol_name);
	}
	return 0;