All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	Linux-Fsdevel <linux-fsdevel@vger.kernel.org>,
	Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Andy Lutomirski <luto@amacapital.net>,
	Rob Landley <rob@landley.net>, Miklos Szeredi <miklos@szeredi.hu>,
	Christoph Hellwig <hch@infradead.org>,
	Karel Zak <kzak@redhat.com>,
	"J. Bruce Fields" <bfields@fieldses.org>,
	Fengguang Wu <fengguang.wu@intel.com>,
	tytso@mit.edu
Subject: Re: [GIT PULL] Detaching mounts on unlink for 3.15
Date: Thu, 17 Apr 2014 23:12:03 +0100	[thread overview]
Message-ID: <20140417221203.GC18016@ZenIV.linux.org.uk> (raw)
In-Reply-To: <87tx9rwsz4.fsf@x220.int.ebiederm.org>

On Thu, Apr 17, 2014 at 02:23:27PM -0700, Eric W. Biederman wrote:

> The typically system has about 12 mounts and no mount namespaces.
> Making umount of any kind a rare case.

The typical system has no userns either.  Take a look at e.g. docker
setups (and unless I'm mistaken, they are going to become a serious
usecase for your stuff as well).

> Al my apologies for not picking your favorite solution and in choosing
> not to audit every call to mntput in the tree this week I have made an
> uncommon case slower.
> 
> These bug fixes are important, the code is correct, and it is
> technically straight forward to remove the wait in mntput in most
> cases.
> 
> I am very frustrated that when given lots of opportunities to look at
> and comment on my code it is hard to get you to engage and comment
> unless I send a pull request to Linus.

Sigh...  FYI, here's what was going on through since Sunday: I had been
beating vfs.git#for-next into shape, exactly to avoid the kind of fun
we had this cycle.  With xfstests update in the middle of it, picking
a bunch of fun both in my code and elsewhere.  With any luck, this stuff
is dealt with (see vfs.git on git.kernel.org) and we might be able to
avoid that kind of shit this time around.

Now I can get to your series.  And no, I'm _not_ suggesting an audit of
every mntput() in the tree.  Really.  It's much more limited thing -
we only need to take care of
	* mntput() from kernel threads.  The same kind of situation we
have with final fput(), the same solution works.
	* *KERNEL* vfsmounts; anything without MNT_INTERNAL is fair game
as far as ordering of fs shutdown is concerned.  If it wasn't MNT_INTERNAL,
and we'd done mntput() before destroying some data structures needed for
fs shutdown, we had been fucked anyway - no warranties that mntput() had
been the final one.  Moreover, that means going through kern_unmount() or
simple_release_fs().  Which is trivially dealt with by providing
mntput_sync(mnt) that *will* wait and using it in those two.  Again, if
we have an extra reference (e.g. stuffed into a struct file, etc.) -
we can't rely on mntput() being final.

I'd probably turn mntput_no_expire() into something like
static struct mount *__mntput(struct mount *m)
that would return NULL if nothing needs to be killed and returned m
if m really needs killing.  Leaving the caller to decide what to do
with that puppy.  We have, as it is, exactly two callers - exit path
in sys_umount() and mntput().  So we add two more functions:
static void kill_mnt_async(struct mount *m)
and
static void kill_mnt_sync(struct mount *m)
both being no-op on NULL.  Then in sys_umount() and mntput() we do
	kill_mnt_async(__mntput(mnt));
and in mntput_sync() - kill_mnt_sync(__mntput(mnt));
For that matter, kill_mnt_sync() (basically, your variant with completions)
can be folded into mntput_sync().

kill_mnt_async() would be a direct analog of this:
                struct task_struct *task = current;

                if (likely(!in_interrupt() && !(task->flags & PF_KTHREAD))) {
                        init_task_work(&file->f_u.fu_rcuhead, ____fput);
                        if (!task_work_add(task, &file->f_u.fu_rcuhead, true))
                                return;
                        /*
                         * After this task has run exit_task_work(),
                         * task_work_add() will fail.  Fall through to delayed
                         * fput to avoid leaking *file.
                         */
                }

                if (llist_add(&file->f_u.fu_llist, &delayed_fput_list))
                        schedule_delayed_work(&delayed_fput_work, 1);
with obvious replacements.  Works for struct file, will work here as well.

That's all.  And yes, I believe that such series would make sense on its
own and once it survives beating (see above about docker - that bastard has
surprised me quite a bit re stressing namespace-related codepaths), I would
be quite willing to help with getting it merged.

  reply	other threads:[~2014-04-17 22:12 UTC|newest]

Thread overview: 181+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-14 17:42 DoS with unprivileged mounts Miklos Szeredi
2013-08-14 19:26 ` Andy Lutomirski
2013-08-14 19:53   ` Eric W. Biederman
2013-08-14 20:25     ` Andy Lutomirski
2013-08-14 21:54       ` Eric W. Biederman
2013-08-14 19:32 ` Eric W. Biederman
2013-08-15  4:59   ` Miklos Szeredi
2013-08-15  6:45     ` Eric W. Biederman
2013-08-15  6:52       ` Andy Lutomirski
2013-08-15  7:55         ` Eric W. Biederman
2013-08-15  9:29       ` Miklos Szeredi
2013-10-04 22:41         ` [RFC][PATCH 0/3] vfs: Detach mounts on unlink Eric W. Biederman
2013-10-04 22:42           ` [RFC][PATCH 1/3] vfs: Keep a list of mounts on a mount point Eric W. Biederman
2013-10-08 13:44             ` Miklos Szeredi
2013-10-08 20:31               ` Eric W. Biederman
2013-10-04 22:43           ` [RFC][PATCH 2/3] vfs: Add a function to lazily unmount all mounts from any dentry Eric W. Biederman
2013-10-07  4:22             ` Serge E. Hallyn
2013-10-07  6:15               ` Eric W. Biederman
2013-10-08 13:56             ` Miklos Szeredi
2013-10-08 20:32               ` Eric W. Biederman
2013-10-04 22:43           ` [RFC][PATCH 3/3] vfs: Lazily remove mounts on unlinked files and directories Eric W. Biederman
2013-10-08 15:50             ` Miklos Szeredi
2013-10-08 21:47               ` Eric W. Biederman
2013-10-09 19:12                 ` Grrrr fusermount Eric W. Biederman
2013-10-09 20:09                   ` Andy Lutomirski
2013-10-09 23:35                     ` Eric W. Biederman
2013-10-04 23:20           ` [RFC][PATCH 0/3] vfs: Detach mounts on unlink Linus Torvalds
2013-10-05  0:03             ` Eric W. Biederman
2013-10-05  1:57               ` Eric W. Biederman
2013-10-05 23:42               ` Rob Landley
2013-10-06  0:44                 ` Eric W. Biederman
2013-10-08  8:03                 ` Karel Zak
2013-10-10  6:46                   ` Rob Landley
2013-10-05  2:34           ` [RFC][PATCH 4/3] vfs: Allow rmdir to remove mounts in all but the current mount namespace Eric W. Biederman
2013-10-05 15:44             ` Serge E. Hallyn
2013-10-07  4:39             ` Serge E. Hallyn
2013-10-07  6:55               ` Eric W. Biederman
2013-10-07 16:53                 ` Andy Lutomirski
2013-10-07 22:25                   ` Eric W. Biederman
2013-10-08 16:06                     ` Miklos Szeredi
2013-10-08 16:06                       ` Andy Lutomirski
2013-10-08 16:11                         ` Miklos Szeredi
2013-10-08 20:50                           ` Eric W. Biederman
2013-10-10 10:02                             ` Miklos Szeredi
2013-10-10 11:43                               ` Eric W. Biederman
2013-10-10 11:57                                 ` Miklos Szeredi
2013-10-12  1:04                                   ` Eric W. Biederman
2013-10-12  1:39                                     ` Eric W. Biederman
     [not found]                                       ` <87d2nb8dxy.fsf-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2013-10-15 20:15                                         ` [REVIEW][PATCH 0/4] vfs: Detach mounts on unlink Eric W. Biederman
2013-10-15 20:15                                           ` Eric W. Biederman
2013-10-15 20:16                                           ` [REVIEW][PATCH 1/4] vfs: Don't allow overwriting mounts in the current mount namespace Eric W. Biederman
2013-11-03  3:54                                             ` Al Viro
     [not found]                                               ` <20131103035406.GA8537-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
2013-11-08 20:51                                                 ` Eric W. Biederman
2013-11-08 20:51                                                   ` Eric W. Biederman
2013-11-08 21:35                                                   ` Al Viro
     [not found]                                                     ` <20131108213551.GR13318-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
2013-11-08 22:17                                                       ` Eric W. Biederman
2013-11-08 22:17                                                         ` Eric W. Biederman
     [not found]                                                         ` <87fvr61qtg.fsf-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2013-11-09  8:49                                                           ` Christoph Hellwig
2013-11-09  8:49                                                             ` Christoph Hellwig
     [not found]                                                             ` <20131109084916.GA21413-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2013-11-21 20:58                                                               ` Eric W. Biederman
2013-11-21 20:58                                                                 ` Eric W. Biederman
     [not found]                                                   ` <87bo1u8vmf.fsf-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2013-11-08 21:35                                                     ` Al Viro
2013-11-21 20:49                                                 ` Eric W. Biederman
2013-11-21 20:49                                                   ` Eric W. Biederman
     [not found]                                             ` <87d2n6xpan.fsf_-_-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2013-10-22 19:04                                               ` Serge E. Hallyn
2013-10-22 19:04                                                 ` Serge E. Hallyn
2013-11-03  3:54                                               ` Al Viro
     [not found]                                           ` <87iowyxpci.fsf_-_-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2013-10-15 20:16                                             ` Eric W. Biederman
2013-10-15 20:17                                             ` [REVIEW][PATCH 2/4] vfs: Keep a list of mounts on a mount point Eric W. Biederman
2013-10-15 20:17                                               ` Eric W. Biederman
     [not found]                                               ` <877gdexp9s.fsf_-_-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2013-10-22 19:06                                                 ` Serge E. Hallyn
2013-10-22 19:06                                                   ` Serge E. Hallyn
2013-10-15 20:17                                             ` [REVIEW][PATCH 3/4] vfs: Add a function to lazily unmount all mounts from any dentry. v3 Eric W. Biederman
2013-10-15 20:17                                               ` Eric W. Biederman
     [not found]                                               ` <871u3mxp8s.fsf_-_-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2013-10-22 19:08                                                 ` Serge E. Hallyn
2013-10-22 19:08                                                   ` Serge E. Hallyn
2013-10-15 20:18                                             ` [REVIEW][PATCH 4/4] vfs: Lazily remove mounts on unlinked files and directories. v2 Eric W. Biederman
2013-10-15 20:18                                               ` Eric W. Biederman
     [not found]                                               ` <87vc0ywan7.fsf_-_-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2013-10-22 19:13                                                 ` Serge E. Hallyn
2013-10-22 19:13                                                   ` Serge E. Hallyn
2013-10-08 10:42                 ` [RFC][PATCH 4/3] vfs: Allow rmdir to remove mounts in all but the current mount namespace Matthias Schniedermeyer
2013-10-08 13:13                   ` Eric W. Biederman
2013-10-05 23:07           ` [RFC][PATCH 0/3] vfs: Detach mounts on unlink Rob Landley
2013-10-05 23:17             ` Linus Torvalds
2013-10-05 23:22               ` Linus Torvalds
2013-10-06  0:18                 ` Rob Landley
2013-10-06  0:37                   ` Linus Torvalds
2013-10-05 23:24               ` Al Viro
2013-10-06  0:22                 ` Rob Landley
2013-10-06  0:12               ` Rob Landley
2013-10-05 23:19             ` Al Viro
2013-10-06  0:13               ` Rob Landley
2014-02-15 21:34           ` [PATCH 0/11] Detaching " Eric W. Biederman
2014-02-15 21:35             ` [PATCH 01/11] vfs: Document the effect of d_revalidate on d_find_alias Eric W. Biederman
2014-02-15 21:36             ` [PATCH 02/11] vfs: More precise tests in d_invalidate Eric W. Biederman
2014-02-15 22:51               ` Linus Torvalds
2014-02-15 22:59                 ` Linus Torvalds
2014-02-15 23:23                   ` Eric W. Biederman
2014-02-15 23:39                     ` Eric W. Biederman
2014-02-16  0:03                     ` Linus Torvalds
2014-02-16  1:22                       ` Eric W. Biederman
2014-02-15 21:36             ` [PATCH 03/11] vfs: Don't allow overwriting mounts in the current mount namespace Eric W. Biederman
2014-02-18 17:12               ` Miklos Szeredi
2014-02-18 21:28                 ` Eric W. Biederman
2014-02-18 22:20                   ` Linus Torvalds
2014-02-19  2:23                     ` Stephen Rothwell
2014-02-24 23:43                       ` Eric W. Biederman
2014-02-15 21:37             ` [PATCH 04/11] vfs: Keep a list of mounts on a mount point Eric W. Biederman
2014-02-15 21:37             ` [PATCH 05/11] vfs: Add a function to lazily unmount all mounts from any dentry Eric W. Biederman
2014-02-16  1:50               ` Eric W. Biederman
2014-02-18 17:17               ` Miklos Szeredi
2014-02-25  3:24                 ` Eric W. Biederman
2014-02-15 21:38             ` [PATCH 06/11] vfs: Lazily remove mounts on unlinked files and directories Eric W. Biederman
2014-02-15 21:38             ` [PATCH 07/11] vfs: Remove unnecessary calls of check_submounts_and_drop Eric W. Biederman
2014-02-15 21:39             ` [PATCH 08/11] vfs: Merge check_submounts_and_drop and d_invalidate Eric W. Biederman
2014-02-18 17:40               ` Miklos Szeredi
2014-02-25  0:01                 ` Eric W. Biederman
2014-02-25 15:13                   ` J. Bruce Fields
2014-02-25 22:03                     ` Eric W. Biederman
2014-02-26 19:37                       ` J. Bruce Fields
2014-02-27  2:05                         ` Eric W. Biederman
2014-02-15 21:39             ` [PATCH 09/11] vfs: Make d_invalidate return void Eric W. Biederman
2014-02-15 21:40             ` [PATCH 10/11] vfs: Remove d_drop calls from d_revalidate implementations Eric W. Biederman
2014-02-15 21:40             ` [PATCH 11/11] proc: Update proc_flush_task_mnt to use d_invalidate Eric W. Biederman
2014-02-18 17:43             ` [PATCH 0/11] Detaching mounts on unlink Miklos Szeredi
2014-02-25  9:33             ` [PATCH 0/12] Detaching mounts on unlink (for 3.15 v2) Eric W. Biederman
2014-02-25  9:34               ` [PATCH 01/12] vfs: Document the effect of d_revalidate on d_find_alias Eric W. Biederman
2014-02-25  9:35               ` [PATCH 02/12] vfs: More precise tests in d_invalidate Eric W. Biederman
2014-02-25  9:35               ` [PATCH 03/12] vfs: Don't allow overwriting mounts in the current mount namespace Eric W. Biederman
2014-02-25  9:36               ` [PATCH 04/12] vfs: Keep a list of mounts on a mount point Eric W. Biederman
2014-02-25  9:37               ` [PATCH 05/12] vfs: factor out lookup_mountpoint from new_mountpoint Eric W. Biederman
2014-02-25  9:38               ` [PATCH 06/12] vfs: Add a function to lazily unmount all mounts from any dentry Eric W. Biederman
2014-02-25  9:38               ` [PATCH 07/12] vfs: Lazily remove mounts on unlinked files and directories Eric W. Biederman
2014-02-25  9:39               ` [PATCH 08/12] vfs: Remove unnecessary calls of check_submounts_and_drop Eric W. Biederman
2014-02-25  9:40               ` [PATCH 09/12] vfs: Merge check_submounts_and_drop and d_invalidate Eric W. Biederman
2014-02-25  9:40               ` [PATCH 10/12] vfs: Make d_invalidate return void Eric W. Biederman
2014-02-25  9:41               ` [PATCH 11/12] vfs: Remove d_drop calls from d_revalidate implementations Eric W. Biederman
2014-02-25  9:41               ` [PATCH 12/12] proc: Update proc_flush_task_mnt to use d_invalidate Eric W. Biederman
2014-04-09  0:21               ` [GIT PULL] Detaching mounts on unlink for 3.15-rc1 Eric W. Biederman
2014-04-09  2:30                 ` Al Viro
2014-04-09  2:39                   ` Al Viro
2014-04-09  9:02                     ` Eric W. Biederman
2014-04-09 17:32                     ` Eric W. Biederman
2014-04-09 17:53                       ` Al Viro
2014-04-09 18:28                         ` Al Viro
2014-04-09 22:49                           ` Eric W. Biederman
2014-04-09 22:58                             ` [RFC][PATCH] vfs: In mntput run deactivate_super on a shallow stack Eric W. Biederman
2014-04-09 23:24                               ` Al Viro
2014-04-10  1:36                                 ` Eric W. Biederman
2014-04-12 22:15                                 ` Eric W. Biederman
2014-04-13  5:39                                   ` Al Viro
2014-04-13  5:49                                     ` Al Viro
2014-04-13  7:01                                     ` Eric W. Biederman
2014-04-13  7:51                                       ` Eric W. Biederman
2014-04-13 21:52                                         ` Al Viro
2014-04-14  7:38                                           ` [RFC][PATCH 0/4] No I/O from mntput Eric W. Biederman
2014-04-14  7:40                                             ` [PATCH 1/4] vfs: Remove useless loop in mntput_no_expire Eric W. Biederman
2014-04-14  7:40                                             ` [PATCH 2/4] vfs: Move autoclose of BSD accounting into a work queue Eric W. Biederman
2014-04-14  7:41                                             ` [PATCH 3/4] vfs: In mntput run deactivate_super on a shallow stack Eric W. Biederman
2014-04-14  7:42                                             ` [PATCH 4/4] vfs: Block intuitively in the case of BSD accounting files Eric W. Biederman
2014-04-16 22:03                                             ` [RFC][PATCH 0/4] No I/O from mntput Eric W. Biederman
2014-04-17 20:05                                               ` [GIT PULL] Detaching mounts on unlink for 3.15 Eric W. Biederman
2014-04-17 20:22                                                 ` Al Viro
2014-04-17 21:23                                                   ` Eric W. Biederman
2014-04-17 22:12                                                     ` Al Viro [this message]
2014-04-17 22:14                                                       ` Al Viro
2014-04-18  0:37                                                       ` Al Viro
2014-04-18  0:58                                                         ` Al Viro
2014-04-19  1:35                                                         ` Al Viro
2014-04-19  2:16                                                           ` Al Viro
2014-04-19  7:05                                                             ` Al Viro
2014-04-20  5:41                                                       ` Al Viro
2014-05-11 16:45                                                         ` Al Viro
2014-05-11 17:05                                                           ` Al Viro
2014-08-09  9:34                                                           ` Al Viro
2014-08-09  9:55                                                             ` Eric W. Biederman
2014-08-12 10:17                                                             ` Eric W. Biederman
2014-08-13 13:18                                                               ` Al Viro
2014-08-13 17:18                                                                 ` Eric W. Biederman
2014-04-09 22:01                       ` [GIT PULL] Detaching mounts on unlink for 3.15-rc1 Dave Chinner
2013-08-15 21:23 ` DoS with unprivileged mounts Rob Landley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140417221203.GC18016@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=bfields@fieldses.org \
    --cc=ebiederm@xmission.com \
    --cc=fengguang.wu@intel.com \
    --cc=hch@infradead.org \
    --cc=kzak@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=miklos@szeredi.hu \
    --cc=rob@landley.net \
    --cc=serge@hallyn.com \
    --cc=torvalds@linux-foundation.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.