[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

broken mount behaviour on jessie



Trying to figure out why my schroot builds keep failing after
upgrading to jessie, I finally narrowed it down to broken behaviour with
mount on jessie:

} root@valiant:/mnt# find
} .
} ./tmp1
} ./tmp1/dev
} ./tmp0
} ./tmp0/dev

Two trees, with a dev directory each.

Let's mount /dev and /dev/pts there:

} root@valiant:/mnt# /bin/mount -v -t none -o rw,bind /dev tmp0/dev
} mount: /dev bound on /mnt/tmp0/dev.
} root@valiant:/mnt# /bin/mount -v -t none -o rw,bind /dev/pts tmp0/dev/pts
} mount: /dev/pts bound on /mnt/tmp0/dev/pts.
} root@valiant:/mnt# grep /mnt /proc/mounts
} udev /mnt/tmp0/dev devtmpfs rw,relatime,size=10240k,nr_inodes=3087992,mode=755 0 0
} devpts /mnt/tmp0/dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0

Seems to have worked.  Yay.

Now the second tree:

} root@valiant:/mnt# /bin/mount -v -t none -o rw,bind /dev tmp1/dev
} mount: /dev bound on /mnt/tmp1/dev.
} root@valiant:/mnt# grep /mnt /proc/mounts
} udev /mnt/tmp0/dev devtmpfs rw,relatime,size=10240k,nr_inodes=3087992,mode=755 0 0
} devpts /mnt/tmp0/dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
} udev /mnt/tmp1/dev devtmpfs rw,relatime,size=10240k,nr_inodes=3087992,mode=755 0 0

So far, so good.  Now for /dev/pts:

} root@valiant:/mnt# /bin/mount -v -t none -o rw,bind /dev/pts tmp1/dev/pts
} mount: /dev/pts bound on /mnt/tmp1/dev/pts.
} root@valiant:/mnt# grep /mnt /proc/mounts
} udev /mnt/tmp0/dev devtmpfs rw,relatime,size=10240k,nr_inodes=3087992,mode=755 0 0
} devpts /mnt/tmp0/dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
} udev /mnt/tmp1/dev devtmpfs rw,relatime,size=10240k,nr_inodes=3087992,mode=755 0 0
} devpts /mnt/tmp1/dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
} devpts /mnt/tmp0/dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0

Something's fishy here.  Note how there is now a second mount on
tmp0/dev/pts.


This is a real problem as exhibited in these two use-cases:

o) you cannot unmount the tmp0 tree while the tmp1 tree is busy:

} root@valiant:/mnt# (cd tmp1/dev/pts ; sleep 10 &)
} root@valiant:/mnt# umount /mnt/tmp0/dev/pts
} umount: /mnt/tmp0/dev/pts: target is busy
}         (In some cases useful info about processes that
}          use the device is found by lsof(8) or fuser(1).)

o) if it's not busy, and you try to umount the tmp0 tree, you mess with
   the tmp1 tree instead:

} root@valiant:/mnt# ls /mnt/tmp0/dev/pts
} 0  1  10  11  13  14  15  16  17  18  19  2  20  21  22  23  24  25  26  3  4  5  6  7  8  ptmx
} root@valiant:/mnt# ls /mnt/tmp1/dev/pts
} 0  1  10  11  13  14  15  16  17  18  19  2  20  21  22  23  24  25  26  3  4  5  6  7  8  ptmx
} root@valiant:/mnt# umount /mnt/tmp0/dev/pts
} root@valiant:/mnt# ls /mnt/tmp0/dev/pts
} 0  1  10  11  13  14  15  16  17  18  19  2  20  21  22  23  24  25  26  3  4  5  6  7  8  ptmx
} root@valiant:/mnt# ls /mnt/tmp1/dev/pts
} root@valiant:/mnt#

It has been suggested on IRC that this is due to systemd mounting
filesystems with O_SHARE.  Regardless of why, these two things at the
bottom are horribly broken.  We need to fix this somehow.

Cheers,
-- 
                            |  .''`.       ** Debian **
      Peter Palfrader       | : :' :      The  universal
 https://www.palfrader.org/ | `. `'      Operating System
                            |   `-    https://www.debian.org/


Reply to: