From: Amir Goldstein <amir73il@gmail.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: linux-unionfs@vger.kernel.org
Subject: [PATCH 09/10] ovl: verify origin of merge dir lower
Date: Tue, 11 Jul 2017 15:58:42 +0300 [thread overview]
Message-ID: <1499777923-29410-10-git-send-email-amir73il@gmail.com> (raw)
In-Reply-To: <1499777923-29410-1-git-send-email-amir73il@gmail.com>
When inodes index feature is enabled, verify that lower merge dir found
by name matches the origin file handle stored in xattr on upper dir.
If origin xattr does not exist, update it with the lower found by name.
If lower dir does not match the origin fh stored in upper dir, do not
merge the lower dir and treat upper dir as pure upper. This behavior
is not friendy to the use case of copied overlay layers, where origin
file handles are broken, but trying to mount an overlay with inodes
index enabled is going to fail anyway for copied layers.
Setting the origin xattr on the upper merge dir also serves as an
indication that this dir may contain whiteouts, which is going to be
used to prevent exposing whiteouts to readdir() in case lower dir was
removed while overlay was offline.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
Documentation/filesystems/overlayfs.txt | 16 ++++++++++++++++
fs/overlayfs/namei.c | 10 ++++++++++
2 files changed, 26 insertions(+)
diff --git a/Documentation/filesystems/overlayfs.txt b/Documentation/filesystems/overlayfs.txt
index 36f528a7fdd6..9b9e8efc3977 100644
--- a/Documentation/filesystems/overlayfs.txt
+++ b/Documentation/filesystems/overlayfs.txt
@@ -262,6 +262,22 @@ filesystem are not allowed. If the underlying filesystem is changed,
the behavior of the overlay is undefined, though it will not result in
a crash or deadlock.
+When the underlying filesystems supports NFS export, overlay mount can be
+made more resilient to offline and online changes of the underlying lower
+layer by enabling the "inodes index" feature.
+
+On every copy_up, an NFS file handle of the lower inode, along with the
+UUID of the lower filesystem, are encoded and stored in an extended
+attribute "trusted.overlay.origin" on the upper inode.
+
+With the "inodes index" feature, a lookup of a merged directory, that
+found a lower directory at the lookup path or at the path pointed to by
+the "trusted.overlay.redirect" extended attribute, will verify that the
+found lower directory file handle and lower filesystem UUID match the
+origin file handle that was stored at copy_up time. If a found lower
+directory does not match the stored origin, that directory will be not be
+merged with the upper directory.
+
Testsuite
---------
diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
index 86f09230a3db..ec81d27b12be 100644
--- a/fs/overlayfs/namei.c
+++ b/fs/overlayfs/namei.c
@@ -648,6 +648,16 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
if (!this)
continue;
+ /* Verify that uppermost lower matches the copy up origin fh */
+ if (this && upperdentry && !ctr && ovl_indexdir(dentry->d_sb)) {
+ err = ovl_verify_origin(upperdentry, lowerpath.mnt,
+ this, false, true);
+ if (err) {
+ dput(this);
+ break;
+ }
+ }
+
stack[ctr].dentry = this;
stack[ctr].mnt = lowerpath.mnt;
ctr++;
--
2.7.4
next prev parent reply other threads:[~2017-07-11 12:58 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-11 12:58 [PATCH 00/10] overlayfs assorted fixes for v4.13 Amir Goldstein
2017-07-11 12:58 ` [PATCH 01/10] ovl: mark parent impure on ovl_link() Amir Goldstein
2017-07-11 12:58 ` [PATCH 02/10] ovl: fix random return value on mount Amir Goldstein
2017-07-11 12:58 ` [PATCH 03/10] ovl: fix origin verification of index dir Amir Goldstein
2017-07-11 12:58 ` [PATCH 04/10] ovl: remove unneeded check for IS_ERR() Amir Goldstein
2017-07-11 12:58 ` [PATCH 05/10] ovl: suppress file handle support warnings on read-only mount Amir Goldstein
2017-07-11 12:58 ` [PATCH 06/10] ovl: force read-only mount with no index dir Amir Goldstein
2017-07-13 20:11 ` Miklos Szeredi
2017-07-14 6:11 ` Amir Goldstein
2017-07-14 9:47 ` Miklos Szeredi
2017-07-11 12:58 ` [PATCH 07/10] ovl: mount overlay read-only on failure to verify " Amir Goldstein
2017-07-13 20:13 ` Miklos Szeredi
2017-07-14 6:51 ` Amir Goldstein
2017-07-14 10:05 ` Miklos Szeredi
2017-07-14 10:35 ` Amir Goldstein
2017-07-14 10:53 ` Miklos Szeredi
2017-07-14 11:17 ` Amir Goldstein
2017-07-24 8:33 ` Miklos Szeredi
2017-08-07 16:12 ` Amir Goldstein
2017-07-11 12:58 ` [PATCH 08/10] ovl: do not cleanup directory and whiteout index entries Amir Goldstein
2017-07-11 12:58 ` Amir Goldstein [this message]
2017-07-11 12:58 ` [PATCH 10/10] ovl: follow decoded origin file handle of merge dir Amir Goldstein
2017-07-13 20:19 ` Miklos Szeredi
2017-07-14 7:42 ` Amir Goldstein
2017-07-14 10:21 ` Miklos Szeredi
2017-07-14 10:58 ` Amir Goldstein
2017-07-24 8:48 ` Miklos Szeredi
2017-07-24 12:14 ` Amir Goldstein
2017-07-25 11:33 ` Miklos Szeredi
2017-07-25 14:30 ` Amir Goldstein
2017-07-25 15:16 ` Miklos Szeredi
2017-07-25 22:19 ` Amir Goldstein
2017-07-26 8:47 ` Miklos Szeredi
2017-07-26 8:51 ` Miklos Szeredi
2017-07-26 8:54 ` Miklos Szeredi
2017-07-26 19:06 ` Amir Goldstein
2017-07-11 19:32 ` [PATCH 00/10] overlayfs assorted fixes for v4.13 Amir Goldstein
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=1499777923-29410-10-git-send-email-amir73il@gmail.com \
--to=amir73il@gmail.com \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
/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