From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anders Blomdell Subject: It would be preferable to do a mount --bind --make-private in one atomic action Date: Wed, 23 Nov 2011 15:05:28 +0100 Message-ID: <4ECCFDA8.7090704@control.lth.se> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE To: Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Return-path: Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org The rationale is the race problems I recently found with pam_namspace=20 (see https://bugzilla.redhat.com/show_bug.cgi?id=3D755216). The followi= ng=20 small script and it's output shows what pam_namespace essentially does=20 does, and the problems that might occur; assume that /work is=20 automounted, then the following really confuses things: ( echo '# Empty work' findmnt | cut -c1-30 | grep work echo '# First primary mount on work' ls -ld /work/Fedora-16/. findmnt | cut -c1-30 | grep work unshare --mount -- /bin/sh -c "( mount --bind /work /work ; mount --make-private /work ; mount --bind /tmp /work ; echo '# Detached mount of work' ; findmnt | cut -c1-30 | grep work ; sleep 5 ; echo '# Before detached unmount of private work' ; findmnt | cut -c1-30 | grep work; umount /work ; echo '# Before detached unmount of bound work' ; findmnt | cut -c1-30 | grep work; echo '# Weird detached automount behaviour' ; ls -ld /work/Fedora-15/. ; umount /work ; echo '# Detached unmount') &" sleep 1 echo '# Second primary mount on work' ls -ld /work/Fedora-15/. findmnt | cut -c1-30 | grep work echo '# First primary mount on work no longer accessible' ls -ld /work/Fedora-16/. sleep 10 echo '# And the final remaining cruft' findmnt | cut -c1-30 | grep work ) Which gives the following output (no wonder I had problems understandin= g=20 what went wrong with my machines :-(): # Empty work =E2=94=9C=E2=94=80/work # First primary mount on work drwxr-xr-x 4 root root 4096 Nov 23 09:37 /work/Fedora-16/. =E2=94=9C=E2=94=80/work =E2=94=82 =E2=94=94=E2=94=80/work/Fedora-16 # Detached mount of work =E2=94=9C=E2=94=80/work =E2=94=82 =E2=94=9C=E2=94=80/work/Fedora-16 =E2=94=82 =E2=94=94=E2=94=80/work =E2=94=82 =E2=94=94=E2=94=80/work # Second primary mount on work drwxr-xr-x 4 root root 4096 Nov 23 09:36 /work/Fedora-15/. =E2=94=9C=E2=94=80/work =E2=94=82 =E2=94=9C=E2=94=80/work/Fedora-16 =E2=94=82 =E2=94=9C=E2=94=80/work =E2=94=82 =E2=94=82 =E2=94=94=E2=94=80/work/Fedora-15 =E2=94=82 =E2=94=94=E2=94=80/work/Fedora-15 # First primary mount on work no longer accessible ls: cannot access /work/Fedora-16/.: Too many levels of symbolic links # Before detached unmount of private work =E2=94=9C=E2=94=80/work =E2=94=82 =E2=94=9C=E2=94=80/work/Fedora-16 =E2=94=82 =E2=94=9C=E2=94=80/work =E2=94=82 =E2=94=82 =E2=94=94=E2=94=80/work =E2=94=82 =E2=94=94=E2=94=80/work/Fedora-15 # Before detached unmount of bound work =E2=94=9C=E2=94=80/work =E2=94=82 =E2=94=9C=E2=94=80/work/Fedora-16 =E2=94=82 =E2=94=9C=E2=94=80/work =E2=94=82 =E2=94=94=E2=94=80/work/Fedora-15 # Weird detached automount behaviour ls: cannot access /work/Fedora-15/.: Too many levels of symbolic links # Detached unmount # And the final remaining cruft =E2=94=9C=E2=94=80/work =E2=94=82 =E2=94=9C=E2=94=80/work/Fedora-16 =E2=94=82 =E2=94=9C=E2=94=80/work =E2=94=82 =E2=94=82 =E2=94=94=E2=94=80/work/Fedora-15 =E2=94=82 =E2=94=94=E2=94=80/work/Fedora-15 --=20 Anders Blomdell Email: anders.blomdell@control.lth.se Department of Automatic Control Lund University Phone: +46 46 222 4625 P.O. Box 118 Fax: +46 46 138118 SE-221 00 Lund, Sweden