linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Miklos Szeredi <mszeredi@redhat.com>
Cc: linux-unionfs@vger.kernel.org, Guillem Jover <guillem@debian.org>,
	Raphael Hertzog <hertzog@debian.org>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] ovl: redirect on rename-dir
Date: Fri, 28 Oct 2016 17:15:34 +0100	[thread overview]
Message-ID: <20161028161534.GM19539@ZenIV.linux.org.uk> (raw)
In-Reply-To: <1477380887-21333-4-git-send-email-mszeredi@redhat.com>

On Tue, Oct 25, 2016 at 09:34:47AM +0200, Miklos Szeredi wrote:
> Current code returns EXDEV when a directory would need to be copied up to
> move.  We could copy up the directory tree in this case, but there's
> another solution: point to old lower directory from moved upper directory.
> 
> This is achieved with a "trusted.overlay.redirect" xattr storing the path
> relative to the root of the overlay.  After such attribute has been set,
> the directory can be moved without further actions required.
> 
> This is a backward incompatible feature, old kernels won't be able to
> correctly mount an overlay containing redirected directories.

> +			err = vfs_path_lookup(lowerpath.dentry, lowerpath.mnt,
> +					      redirect, 0, &thispath);
> +
> +			if (err) {
> +				if (err == -ENOENT || err == -ENAMETOOLONG)
> +					this = NULL;
> +			} else {
> +				this = thispath.dentry;
> +				mntput(thispath.mnt);
> +				if (!this->d_inode) {
> +					dput(this);
> +					this = NULL;
> +				} else if (ovl_dentry_weird(this)) {
> +					dput(this);
> +					err = -EREMOTE;
> +				}
> +			}

I'm not happy with that one - you are relying upon the fairly subtle
assertions here.
	1)  Had lowerpath.mnt *not* been a privately cloned one with nothing
mounted on it, you would've been screwed.
	2) Had that thing contained a "jumper" symlink (a-la procfs ones),
you would've been screwed.  Currently only procfs has those, and it would've
been rejected before getting there, but this is brittle and non-obvious.
	3) Any automount point in there (nfs4 referrals, etc.) can
break the assumption that nothing could've been mounted on it.  And _that_
might have not been stepped onto; back when the path had been stored, there'd
been no automount point at all, so we have avoided ovl_dentry_weird() rejects,
and by now nothing on the path had been visited yet, so ovl_dentry_weird()
didn't have a chance to trigger.  Note that calling it on the last dentry
is no good - we might have crossed the automount point in the middle of that
path, so this last dentry might be nice and shiny - and on another filesystem.
So unlike (1) and (2) it's not just a fishy-looking thing that happens to
work for non-local reasons; AFAICS, it's actually a bug.

I'm not sure if vfs_path_lookup() is the right tool here.  It might be
usable for making such a tool, but as it is you are setting one hell of
a trap for yourself...

It might be made to work, if we figure out the right semantics for disabling
symlinks on per-vfsmount basis (and no, the posted nolinks patches are not
it) and mark these private clones with that and with similar "disable
automount traversals" flag (again, needs the right semantics; the area is
convoluted as it is).  But in that case I would strongly recommend adding
an exported wrapper around vfs_path_lookup() that would verify that these
flags *are* set.

  parent reply	other threads:[~2016-10-28 16:15 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-25  7:34 [PATCH 0/3] overlayfs: allow moving directory trees Miklos Szeredi
2016-10-25  7:34 ` [PATCH 1/3] ovl: check fs features Miklos Szeredi
2016-10-25 11:24   ` Amir Goldstein
2016-11-05 20:40     ` Amir Goldstein
2016-10-25  7:34 ` [PATCH 2/3] vfs: export vfs_path_lookup() Miklos Szeredi
2016-10-25  7:34 ` [PATCH 3/3] ovl: redirect on rename-dir Miklos Szeredi
2016-10-25 11:57   ` Raphael Hertzog
2016-10-26 11:12     ` Miklos Szeredi
2016-10-28 12:56       ` Raphael Hertzog
2016-10-28 12:59         ` Miklos Szeredi
2016-11-06 19:14       ` Konstantin Khlebnikov
2016-11-07  8:07         ` Miklos Szeredi
2016-11-07  9:58           ` Konstantin Khlebnikov
2016-11-07 10:04             ` Miklos Szeredi
2016-11-07 10:08               ` Konstantin Khlebnikov
2016-11-07 13:38                 ` Amir Goldstein
2016-11-10 22:56                   ` Amir Goldstein
2016-11-11  9:46                     ` Konstantin Khlebnikov
2016-11-11 10:06                       ` Miklos Szeredi
2016-11-11 12:42                         ` Amir Goldstein
2016-11-13  9:11                           ` Amir Goldstein
2016-11-07 11:03         ` Raphael Hertzog
2016-11-07 11:31           ` Konstantin Khlebnikov
2016-11-07 13:42             ` Raphael Hertzog
2016-11-10 22:39               ` Miklos Szeredi
2016-11-11  9:41                 ` Konstantin Khlebnikov
2016-11-13 10:00                 ` Amir Goldstein
2016-11-14 16:25                   ` Amir Goldstein
2016-11-16 22:00                     ` Miklos Szeredi
2016-11-18 15:37                       ` Amir Goldstein
2016-11-20 11:39                         ` Amir Goldstein
2016-11-21  9:54                         ` Miklos Szeredi
2016-11-21 10:13                           ` Amir Goldstein
2016-11-21 10:16                             ` Miklos Szeredi
2016-11-22 13:42                               ` Amir Goldstein
2016-10-25 12:49   ` Amir Goldstein
2016-10-26 11:26     ` Miklos Szeredi
2016-10-26 12:11       ` Amir Goldstein
2016-10-26 12:51         ` Miklos Szeredi
2016-10-26 19:56       ` Amir Goldstein
2016-10-30 22:00       ` Amir Goldstein
2016-10-31 14:59         ` Miklos Szeredi
2016-10-31 15:02           ` Amir Goldstein
2016-10-28 16:15   ` Al Viro [this message]
2016-11-03 15:50     ` Miklos Szeredi
2016-11-04  9:29       ` Amir Goldstein
2016-11-04 13:48         ` Miklos Szeredi
2016-10-25 20:25 ` [PATCH 0/3] overlayfs: allow moving directory trees Amir Goldstein
2016-10-26  9:37   ` Amir Goldstein
2016-10-26  9:34 ` [PATCH] ovl: check for emptiness of redirect dir Amir Goldstein
2016-10-26 10:45   ` Miklos Szeredi

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=20161028161534.GM19539@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=guillem@debian.org \
    --cc=hertzog@debian.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=mszeredi@redhat.com \
    /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;
as well as URLs for NNTP newsgroup(s).