Bug 193094 - 'mount' mounts wrong filesystem with bind mounts
Summary: 'mount' mounts wrong filesystem with bind mounts
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: util-linux
Version: 5
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Karel Zak
QA Contact: Ben Levenson
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2006-05-25 07:53 UTC by Avi Kivity
Modified: 2008-03-09 10:30 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2006-08-21 15:29:59 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
fix - ignore device nodes that are regular files or directories (891 bytes, patch)
2006-05-25 07:53 UTC, Avi Kivity
no flags Details | Diff

Description Avi Kivity 2006-05-25 07:53:09 UTC
Description of problem:

mount can accept either a device node or a mountpoint if the filesystem is 
in /etc/fstab. unfortunately, with bind (and loop) mounts, a file or directory 
can appear as both the device node or the mountpoint (in different entries), 
making a simple 'mount /blah' ambiguous.

Version-Release number of selected component (if applicable):
util-linux-2.13-0.20.1

How reproducible:
$ grep /test /etc/fstab
/dev/VolGroup00/tmp     /test                   ext3    defaults        0 0
/test                   /test1                  none    bind            0 0

$ sudo mount /test

-> /test1 mounted instead of /test.


Steps to Reproduce:
1. have a filesystem in /fstab also be the source of a bind mount
2. try to mount it
  
Actual results:
the bind mount is mounted instead of the filesystem

Expected results:
filesystem mounted

Note:
bind mounts are important for nfs4 exports and for setting chrooted 
environments (FC5-in-FC4, etc.)

Comment 1 Avi Kivity 2006-05-25 07:53:09 UTC
Created attachment 129975 [details]
fix - ignore device nodes that are regular files or directories

Comment 2 Karel Zak 2006-08-21 15:29:59 UTC
It's not so simple. Your patch completely disable mount by /path/file.img for
loop devices. You also forget that no all people use ambiguous configuration and
use bind mount by source directories is fine for them. 

I think rather than add to code some non-transparent heuristic is better use for
example mount by LABEL/UUID/device for your /dev/VolGroup00/tmp.

Comment 3 Avi Kivity 2006-08-21 15:50:05 UTC
bind mounts cannot use LABEL/UUID/device.

Perhaps disambiguate by using a prefix:

mount device:/path/file.img   # by device
mount /dev/devicenode         # by device
mount /path/mountpoint        # by mountpoint

?

I can do the patch.

Comment 4 Karel Zak 2006-08-21 16:04:45 UTC
Well, I didn't talk about LABEL/UUID/device for bind mount. Let's use:

  mount /dev/VolGroup00/tmp  (or mount LABEL=foo)

when you need mount the device and

  mount /test1  (or mount /test, because the mount checks fs_spec before fs_file)

when you need bind mount. 
 


Comment 5 Avi Kivity 2006-08-21 16:08:31 UTC
This removes the ambiguity for the case I mentioned, but is ambiguous for 
another.

The core problem is that

# mount x

will match two lines in /etc/fstab (or /etc/mtab):

x blah
blah x

unless we disambiguate, somebody will hit this.  I know I did, and silently 
unexpected behavior with mount/umount can easily be disasterous.

Comment 6 vikram goyal 2008-03-09 10:30:49 UTC
*** Bug 242935 has been marked as a duplicate of this bug. ***


Note You need to log in before you can comment on or make changes to this bug.