Package: mount
Version: 2.12r-6
Severity: grave
Justification: could lead to unexpected data loss or corruption

My daily locate cronjob started giving me funny warnings:

/usr/bin/find: Filesystem loop detected; `//burnside-unstable' has the
same device number and inode as a directory which is 1 level higher in
the filesystem hierarchy.

Weird.

So I investigated further.  I had just upgraded mount from version
2.12p-8 to 2.12r-6.

My /etc/fstab reads as follows (unedited in case this is important):

# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
/dev/hda3       /               ext3    defaults,errors=remount-ro 0       1
/dev/hda5       none            swap    sw              0       0
/dev/hdd        /media/cdrom0   iso9660 ro,user,noauto  0       0
/dev/hdc        /media/dvd      iso9660 ro,user,noauto  0       0
/dev/hdc        /media/dvdudf   udf     ro,user,noauto  0       0
/dev/fd0        /media/floppy0  auto    rw,user,noauto  0       0
/dev/hda2       /burnside-unstable   ext3    defaults        0       2
/dev/hda1       /ntfs           ntfs    ro,umask=0222   0       0
192.168.0.3:/   /polya          nfs     defaults,noauto 0       0
proc-sid /chroot/unstable/proc proc none 0 0
/dev/sda1       /mnt/memstick   vfat    rw,user,noauto  0       0



I ran the following commands:

burnside:~ # ls -l /etc/apt/sources.list
-rw-r--r-- 1 root root 916 Dec  8 23:30 /burnside-unstable/etc/apt/sources.list
burnside:~ # umount /burnside-unstable/
burnside:~ # strace -f mount /burnside-unstable/ > /tmp/mount.fstab 2>&1
burnside:~ # ls -l /burnside-unstable/etc/apt/sources.list
-rw-r--r--  1 root root 916 Dec  8 23:30 /burnside-unstable/etc/apt/sources.list
burnside:~ # umount /burnside-unstable/
burnside:~ # strace -f mount -t ext3 /dev/hda2 /burnside-unstable > 
/tmp/mount.cmd 2>&1
burnside:~ # ls -l /burnside-unstable/etc/apt/sources.list
-rw-r--r-- 1 root root 916 Dec  8 23:30 /burnside-unstable/etc/apt/sources.list
burnside:~ # mount
/dev/hda3 on / type ext3 (rw,errors=remount-ro)
/dev/hda1 on /ntfs type ntfs (ro,umask=0222)
proc-sid on /chroot/unstable/proc type proc (rw,none)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
usbfs on /proc/bus/usb type usbfs (rw)
tmpfs on /dev type tmpfs (rw,size=10M,mode=0755)
/dev/hda2 on /burnside-unstable type ext3 (rw)
burnside:~ # perl -e 'print 
join(":",stat("/burnside-unstable/etc/apt/sources.list")),"\n"'
770:2883606:33188:1:0:0:0:916:1140557993:1134084657:1134084657:4096:8
burnside:~ # perl -e 'print join(":",stat("/etc/apt/sources.list")),"\n"'
770:2883606:33188:1:0:0:0:916:1140557993:1134084657:1134084657:4096:8

So even though /dev/hda2 and /dev/hda3 are different devices, mount is
ending up mounting /dev/hda3 instead of /dev/hda2.

The strace output is included.  The output of cfdisk -P s is:

Partition Table for /dev/hda

               First       Last
 # Type       Sector      Sector   Offset    Length   Filesystem Type (ID) Flag
-- ------- ----------- ----------- ------ ----------- -------------------- ----
 1 Primary           0    51199154     63    51199155 HPFS/NTFS (07)       Boot
 2 Primary    51199155   119555729      0    68356575 Linux (83)           None
   None      119555730   135171791*     0    15616062*Unusable             None
 3 Primary   135171792*  155252159      0    20080368*Linux (83)           None
 4 Primary   155252160   156296384      0     1044225 W95 Ext'd (LBA) (0F) None
 5 Logical   155252160   156296384     63     1044225 Linux swap / So (82) None


$ uname -a
Linux burnside 2.6.15-1-k7 #1 Fri Feb 10 16:09:44 UTC 2006 i686 GNU/Linux

It's also slightly sporadic: I managed to mount /dev/hda2 correctly
from a command line once this evening, but it failed every other time
with exactly the same error.

Mystified,

   Julian
execve("/bin/mount", ["mount", "/burnside-unstable/"], [/* 11 vars */]) = 0
uname({sys="Linux", node="burnside", ...}) = 0
brk(0)                                  = 0x805a000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=92674, ...}) = 0
old_mmap(NULL, 92674, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7f13000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/libblkid.so.1", O_RDONLY)    = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0p\36\0\000"..., 512) = 
512
fstat64(3, {st_mode=S_IFREG|0644, st_size=28556, ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0xb7f12000
old_mmap(NULL, 31576, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 
0xb7f0a000
old_mmap(0xb7f11000, 4096, PROT_READ|PROT_WRITE, 
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0xb7f11000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/libuuid.so.1", O_RDONLY)     = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\320\n\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=8696, ...}) = 0
old_mmap(NULL, 11680, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 
0xb7f07000
old_mmap(0xb7f09000, 4096, PROT_READ|PROT_WRITE, 
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1000) = 0xb7f09000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/tls/i686/cmov/libc.so.6", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\260O\1"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1262704, ...}) = 0
old_mmap(NULL, 1268668, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 
0xb7dd1000
old_mmap(0xb7efd000, 32768, PROT_READ|PROT_WRITE, 
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x12c000) = 0xb7efd000
old_mmap(0xb7f05000, 7100, PROT_READ|PROT_WRITE, 
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7f05000
close(3)                                = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0xb7dd0000
mprotect(0xb7efd000, 20480, PROT_READ)  = 0
set_thread_area({entry_number:-1 -> 6, base_addr:0xb7dd06c0, limit:1048575, 
seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, 
useable:1}) = 0
munmap(0xb7f13000, 92674)               = 0
brk(0)                                  = 0x805a000
brk(0x807b000)                          = 0x807b000
umask(022)                              = 022
open("/dev/null", O_RDWR|O_LARGEFILE)   = 3
close(3)                                = 0
getuid32()                              = 0
geteuid32()                             = 0
getgid32()                              = 0
getegid32()                             = 0
prctl(0x3, 0, 0, 0, 0)                  = 1
open("/etc/blkid.tab", O_RDONLY)        = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=72, ...}) = 0
fcntl64(3, F_GETFL)                     = 0 (flags O_RDONLY)
fstat64(3, {st_mode=S_IFREG|0644, st_size=72, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0xb7f29000
_llseek(3, 0, [0], SEEK_CUR)            = 0
read(3, "<device DEVNO=\"0x0305\" TIME=\"113"..., 4096) = 72
read(3, "", 4096)                       = 0
close(3)                                = 0
munmap(0xb7f29000, 4096)                = 0
getuid32()                              = 0
geteuid32()                             = 0
lstat64("/etc/mtab", {st_mode=S_IFREG|0644, st_size=325, ...}) = 0
readlink("/burnside-unstable", 0xbff3a5fb, 4096) = -1 EINVAL (Invalid argument)
umask(077)                              = 022
open("/etc/fstab", O_RDONLY|O_LARGEFILE) = 3
umask(022)                              = 077
fstat64(3, {st_mode=S_IFREG|0644, st_size=887, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0xb7f29000
read(3, "# /etc/fstab: static file system"..., 4096) = 887
read(3, "", 4096)                       = 0
close(3)                                = 0
munmap(0xb7f29000, 4096)                = 0
stat64("/sbin/mount.ext3", 0xbff3c40c)  = -1 ENOENT (No such file or directory)
rt_sigprocmask(SIG_BLOCK, ~[TRAP SEGV RTMIN RT_1], NULL, 8) = 0
mount("/dev/hda2", "/burnside-unstable", "ext3", 
MS_POSIXACL|MS_ACTIVE|MS_NOUSER|0xec0000, 0x805a300) = 0
readlink("/dev", 0xbff3a46b, 4096)      = -1 EINVAL (Invalid argument)
readlink("/dev/hda2", 0xbff3a46b, 4096) = -1 EINVAL (Invalid argument)
readlink("/burnside-unstable", 0xbff3a46b, 4096) = -1 EINVAL (Invalid argument)
open("/etc/mtab", O_RDWR|O_CREAT|O_LARGEFILE, 0644) = 3
close(3)                                = 0
rt_sigaction(SIGHUP, {0x804ddfe, ~[RTMIN RT_1], 0}, NULL, 8) = 0
rt_sigaction(SIGINT, {0x804ddfe, ~[RTMIN RT_1], 0}, NULL, 8) = 0
rt_sigaction(SIGQUIT, {0x804ddfe, ~[RTMIN RT_1], 0}, NULL, 8) = 0
rt_sigaction(SIGILL, {0x804ddfe, ~[RTMIN RT_1], 0}, NULL, 8) = 0
rt_sigaction(SIGTRAP, {0x804ddfe, ~[RTMIN RT_1], 0}, NULL, 8) = 0
rt_sigaction(SIGABRT, {0x804ddfe, ~[RTMIN RT_1], 0}, NULL, 8) = 0
rt_sigaction(SIGBUS, {0x804ddfe, ~[RTMIN RT_1], 0}, NULL, 8) = 0
rt_sigaction(SIGFPE, {0x804ddfe, ~[RTMIN RT_1], 0}, NULL, 8) = 0
rt_sigaction(SIGKILL, {0x804ddfe, ~[RTMIN RT_1], 0}, NULL, 8) = -1 EINVAL 
(Invalid argument)
rt_sigaction(SIGUSR1, {0x804ddfe, ~[RTMIN RT_1], 0}, NULL, 8) = 0
rt_sigaction(SIGSEGV, {0x804ddfe, ~[RTMIN RT_1], 0}, NULL, 8) = 0
rt_sigaction(SIGUSR2, {0x804ddfe, ~[RTMIN RT_1], 0}, NULL, 8) = 0
rt_sigaction(SIGPIPE, {0x804ddfe, ~[RTMIN RT_1], 0}, NULL, 8) = 0
rt_sigaction(SIGALRM, {0x804de1e, ~[RTMIN RT_1], 0}, NULL, 8) = 0
rt_sigaction(SIGTERM, {0x804ddfe, ~[RTMIN RT_1], 0}, NULL, 8) = 0
rt_sigaction(SIGSTKFLT, {0x804ddfe, ~[RTMIN RT_1], 0}, NULL, 8) = 0
getpid()                                = 23368
open("/etc/mtab~23368", O_WRONLY|O_CREAT|O_LARGEFILE, 0600) = 3
close(3)                                = 0
link("/etc/mtab~23368", "/etc/mtab~")   = 0
unlink("/etc/mtab~23368")               = 0
open("/etc/mtab~", O_WRONLY|O_LARGEFILE) = 3
fcntl64(3, F_SETLK64, {type=F_WRLCK, whence=SEEK_SET, start=0, len=0}, 
0xbff3c400) = 0
close(3)                                = 0
umask(077)                              = 022
open("/etc/mtab", O_RDWR|O_APPEND|O_CREAT|O_LARGEFILE, 0666) = 3
umask(022)                              = 077
fstat64(3, {st_mode=S_IFREG|0644, st_size=325, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0xb7f29000
fstat64(3, {st_mode=S_IFREG|0644, st_size=325, ...}) = 0
_llseek(3, 0, [0], SEEK_SET)            = 0
read(3, "/dev/hda3 / ext3 rw,errors=remou"..., 325) = 325
write(3, "/dev/hda2 /burnside-unstable ext"..., 41) = 41
close(3)                                = 0
munmap(0xb7f29000, 4096)                = 0
unlink("/etc/mtab~")                    = 0
rt_sigprocmask(SIG_UNBLOCK, ~[TRAP SEGV RTMIN RT_1], NULL, 8) = 0
exit_group(0)                           = ?

Reply via email to