From: Amir Goldstein <amir73il@gmail.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: linux-unionfs@vger.kernel.org, "# v4 . 12" <stable@vger.kernel.org>
Subject: [PATCH 01/10] ovl: mark parent impure on ovl_link()
Date: Tue, 11 Jul 2017 15:58:34 +0300 [thread overview]
Message-ID: <1499777923-29410-2-git-send-email-amir73il@gmail.com> (raw)
In-Reply-To: <1499777923-29410-1-git-send-email-amir73il@gmail.com>
When linking a file with copy up origin into a new parent, mark the
new parent dir "impure".
Fixes: ee1d6d37b6b8 ("ovl: mark upper dir with type origin entries "impure"")
Cc: <stable@vger.kernel.org> # v4.12
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
fs/overlayfs/copy_up.c | 4 ++--
fs/overlayfs/dir.c | 20 ++++++++++++++++----
fs/overlayfs/overlayfs.h | 2 +-
fs/overlayfs/util.c | 6 +++---
4 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
index acb6f97deb97..aeb22def9f80 100644
--- a/fs/overlayfs/copy_up.c
+++ b/fs/overlayfs/copy_up.c
@@ -338,7 +338,7 @@ static int ovl_link_up(struct ovl_copy_up_ctx *c)
struct inode *udir = d_inode(upperdir);
/* Mark parent "impure" because it may now contain non-pure upper */
- err = ovl_set_impure(c->parent, upperdir);
+ err = ovl_set_impure(c->parent);
if (err)
return err;
@@ -551,7 +551,7 @@ static int ovl_do_copy_up(struct ovl_copy_up_ctx *c)
* Mark parent "impure" because it may now contain non-pure
* upper
*/
- err = ovl_set_impure(c->parent, c->destdir);
+ err = ovl_set_impure(c->parent);
if (err)
return err;
}
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 641d9ee97f91..5df99952feba 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -92,7 +92,8 @@ int ovl_create_real(struct inode *dir, struct dentry *newdentry,
return -ESTALE;
if (hardlink) {
- err = ovl_do_link(hardlink, dir, newdentry, debug);
+ err = ovl_do_link(ovl_dentry_upper(hardlink), dir, newdentry,
+ debug);
} else {
switch (attr->mode & S_IFMT) {
case S_IFREG:
@@ -492,6 +493,17 @@ static int ovl_create_or_link(struct dentry *dentry, struct inode *inode,
return err;
old_cred = ovl_override_creds(dentry->d_sb);
+
+ /*
+ * When linking a file with copy up origin into a new parent, mark the
+ * new parent dir "impure".
+ */
+ if (hardlink && ovl_type_origin(hardlink)) {
+ err = ovl_set_impure(dentry->d_parent);
+ if (err)
+ goto out_revert_creds;
+ }
+
err = -ENOMEM;
override_cred = prepare_creds();
if (override_cred) {
@@ -609,7 +621,7 @@ static int ovl_link(struct dentry *old, struct inode *newdir,
inode = d_inode(old);
ihold(inode);
- err = ovl_create_or_link(new, inode, NULL, ovl_dentry_upper(old));
+ err = ovl_create_or_link(new, inode, NULL, old);
if (err)
iput(inode);
@@ -987,12 +999,12 @@ static int ovl_rename(struct inode *olddir, struct dentry *old,
* lookup the origin inodes of the entries to fill d_ino.
*/
if (ovl_type_origin(old)) {
- err = ovl_set_impure(new->d_parent, new_upperdir);
+ err = ovl_set_impure(new->d_parent);
if (err)
goto out_revert_creds;
}
if (!overwrite && ovl_type_origin(new)) {
- err = ovl_set_impure(old->d_parent, old_upperdir);
+ err = ovl_set_impure(old->d_parent);
if (err)
goto out_revert_creds;
}
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index 60d26605e039..7aa1c48390a5 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -225,7 +225,7 @@ bool ovl_check_dir_xattr(struct dentry *dentry, const char *name);
int ovl_check_setxattr(struct dentry *dentry, struct dentry *upperdentry,
const char *name, const void *value, size_t size,
int xerr);
-int ovl_set_impure(struct dentry *dentry, struct dentry *upperdentry);
+int ovl_set_impure(struct dentry *dentry);
void ovl_set_flag(unsigned long flag, struct inode *inode);
bool ovl_test_flag(unsigned long flag, struct inode *inode);
bool ovl_inuse_trylock(struct dentry *dentry);
diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c
index c492ba75c659..82c3dad6ddf4 100644
--- a/fs/overlayfs/util.c
+++ b/fs/overlayfs/util.c
@@ -353,7 +353,7 @@ int ovl_check_setxattr(struct dentry *dentry, struct dentry *upperdentry,
return err;
}
-int ovl_set_impure(struct dentry *dentry, struct dentry *upperdentry)
+int ovl_set_impure(struct dentry *dentry)
{
int err;
@@ -364,8 +364,8 @@ int ovl_set_impure(struct dentry *dentry, struct dentry *upperdentry)
* Do not fail when upper doesn't support xattrs.
* Upper inodes won't have origin nor redirect xattr anyway.
*/
- err = ovl_check_setxattr(dentry, upperdentry, OVL_XATTR_IMPURE,
- "y", 1, 0);
+ err = ovl_check_setxattr(dentry, ovl_dentry_upper(dentry),
+ OVL_XATTR_IMPURE, "y", 1, 0);
if (!err)
ovl_set_flag(OVL_IMPURE, d_inode(dentry));
--
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 ` Amir Goldstein [this message]
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 ` [PATCH 09/10] ovl: verify origin of merge dir lower Amir Goldstein
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-2-git-send-email-amir73il@gmail.com \
--to=amir73il@gmail.com \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=stable@vger.kernel.org \
/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