]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commit
libext2fs/ismounted.c: check device id in advance to skip false device names
authorTheodore Ts'o <tytso@mit.edu>
Sun, 10 Nov 2019 17:11:49 +0000 (12:11 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 10 Nov 2019 17:11:49 +0000 (12:11 -0500)
commitea4d53b7b9079fd6e2cc34cf569a993a183bfbd2
tree9a927f787577f07b36c509a09b91416d4bfa8786
parentac94445fc01f070feb31d599d6dfd5fb3d34d3ea
libext2fs/ismounted.c: check device id in advance to skip false device names

If there is a trickster which tries to use device names as the mount
device for pseudo-file systems, the resulting /proc/mounts can confuse
ext2fs_check_mount_point().  (So far as I can tell, there's no good
reason to do this, but sysadmins do the darnest things.)

An example of this might be the following /proc/mounts excerpt:

/dev/sdb /mnt2 tmpfs rw,relatime 0 0
/dev/sdb /mnt ext4 rw,relatime 0 0

This is created via "mount -t tmpfs /dev/sdb /mnt2" followed via
"mount -t ext4 /dev/sdb /mnt".  (Normally, a sane mount of tmpfs would
use something like "mount -t tmpfs tmpfs /mnt2".)

Fix this by double checking the st_rdev of the claimed mountpoint and
match it with the dev_t of the device.  (Note that the GNU HURD
doesn't support st_rdev, so we can't solve this problem for the HURD.)

Reported-by: GuiYao <guiyao@huawei.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/ext2fs/ismounted.c