lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 31 May 2018 20:26:08 +0100
From:   Al Viro <viro@...IV.linux.org.uk>
To:     David Howells <dhowells@...hat.com>
Cc:     linux-fsdevel@...r.kernel.org, linux-afs@...ts.infradead.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 20/32] vfs: Make close() unmount the attached mount if so
 flagged [ver #8]

On Thu, May 31, 2018 at 08:19:55PM +0100, Al Viro wrote:
> On Fri, May 25, 2018 at 01:07:34AM +0100, David Howells wrote:
> > +	if (unlikely(file->f_mode & FMODE_NEED_UNMOUNT))
> > +		__detach_mounts(dentry);
> > +
> 
> This is completely wrong.  First of all, you want to dissolve the mount tree
> on file->f_path.mount, not every tree rooted at dentry equal to file->f_path.dentry.
> This is easily done - it would be a simple call of drop_collected_mounts(mnt)
> if not for one detail.  You want it to happen only if the sucker isn't attached
> anywhere by that point.  IOW,
>         namespace_lock();
>         lock_mount_hash();
> 	if (!real_mount(mnt)->mnt_ns)
> 		umount_tree(real_mount(mnt), UMOUNT_SYNC);
>         unlock_mount_hash();
>         namespace_unlock();
> and that's it.  You don't need that magical mystery turd in move_mount() later
> in the series and all the infrastructure you grow for it.
> 
> FWIW, I would've suggested this
>  void drop_collected_mounts(struct vfsmount *mnt)
>  {
>  	namespace_lock();
>  	lock_mount_hash();
> +	if (!real_mount(mnt)->mnt_ns)
> +		umount_tree(real_mount(mnt), UMOUNT_SYNC);
> -	umount_tree(real_mount(mnt), UMOUNT_SYNC);
>  	unlock_mount_hash();
>  	namespace_unlock();
>  }
> 
> and in __fput()
> 	if (unlikely(file->f_mode & FMODE_NEED_UNMOUNT))
> 		drop_collected_mounts(mnt);
> 
> All there is to it, AFAICS...

... and that eliminates #27 and #28 entirely, with #31 becoming simpler -
no move_mount_lookup(), no dfd_ref, the check in do_move_mount() becomes
+       if (!mnt_has_parent(old) && old->mnt_ns) {
+               /* We need to allow open(O_PATH|O_CLONE_MOUNT) or fsmount()
+                * followed by move_mount(), but mustn't allow "/" to be moved.
+                */
+                goto out1;
+       }
and I wouldn't be surprised if move_mount_old()/move_mount() split turns out
to be not needed at all, seeing that the whole "clear FMODE_NEED_UNMOUNT
on success" part goes away.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ