mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: Jeff Layton <jlayton@kernel.org>,
	"J . Bruce Fields" <bfields@fieldses.org>,
	Arnd Bergmann <arnd@arndb.de>, Paul Moore <paul@paul-moore.com>,
	Richard Guy Briggs <rgb@redhat.com>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>,
	"Andrei Vagin (C)" <avagin@gmail.com>
Subject: Re: [PATCH v2] fs: add new O_MNT flag for opening mount root from mountpoint fd
Date: Fri, 15 Nov 2019 07:37:58 +0000	[thread overview]
Message-ID: <1af96c9c-0e4c-5f18-a710-1db4b6a3cf87@virtuozzo.com> (raw)
In-Reply-To: <20191114141320.GI26530@ZenIV.linux.org.uk>



On 11/14/19 5:13 PM, Al Viro wrote:
> On Thu, Nov 14, 2019 at 12:04:54PM +0300, Pavel Tikhomirov wrote:
> 
>> More precisely the algorithm is:
>> a) openat mpfd to a new mountpoint through parent mount's root -
>> p_rootfd (which we already have) or mountpoint fd under a sibling mount
>> - s_mpfd if our mountpoint is already overmounted.
>> b) create a new mount on mpfd via /proc/<pid>/fd/<N> interface
>> c) openat it's rootfd via O_MNT from mpfd
>>
>> If we have mpfd and rootfd for each mount through /proc/<pid>/fd/<N>
>> interface we will be able to bindmount any part of each of already
>> created mounts to restore other mounts  and we will be able to configure
>> mounts, e.g. change sharing or other options even if mounts are
>> invisible from fs-root.
> 
> Everything else aside (and I'm not thrilled about the idea in general),
> you are not handling the situation when that overmount is, in turn,
> overmounted.

Sorry but I don't understand why overmounted overmount is a special 
case... Let me explain in other words. I use mathematical induction as a 
proof technique. Base of induction is when we have no mounts (exept 
root), it is obvious that we can access all directories in the system. 
Step of induction is when we add one more mount and before that step 
we've had an access to all directories in the system (have mpfds and 
rootfds for all mounts).

If step adds a mount mnt we need to only consider it's parent, siblings 
and children which will be there after the step, all other mounts does 
not change anything.

Propagations of mnt can't become mnt's children or siblings or parent, 
luckily for us. So we can actually consider one mount from propagation 
group at a time.

Now if mp is just visible from parent's p_rootfd we open mpfd. Else we 
have some sibling from which s_mpfd the mp is visible and we open mpfd 
from it. And the last case if we're crawling under some mount (child) we 
can open mpfd through c_mpfd.

Now our mpfd is open so we use O_MNT to open our rootfd. (And here we 
change c_mpfd to our rootfd as our new child switched parent)

>  Or when there's an automount set on top of it, etc.

I'm not common with automounts actually, so I might miss something here. 
Can you please show actual mount tree where this problem can happen?

> 

-- 
Best regards, Tikhomirov Pavel
Software Developer, Virtuozzo.

      reply	other threads:[~2019-11-15  7:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-14  9:04 Pavel Tikhomirov
2019-11-14 14:13 ` Al Viro
2019-11-15  7:37   ` Pavel Tikhomirov [this message]

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=1af96c9c-0e4c-5f18-a710-1db4b6a3cf87@virtuozzo.com \
    --to=ptikhomirov@virtuozzo.com \
    --cc=arnd@arndb.de \
    --cc=avagin@gmail.com \
    --cc=bfields@fieldses.org \
    --cc=jlayton@kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paul@paul-moore.com \
    --cc=rgb@redhat.com \
    --cc=viro@zeniv.linux.org.uk \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®