linux-unionfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vfs: fix may_write_real() for overlayfs directories
@ 2017-09-18 20:21 Amir Goldstein
  0 siblings, 0 replies; only message in thread
From: Amir Goldstein @ 2017-09-18 20:21 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: Eryu Guan, linux-unionfs

Overlayfs directory file_inode() is the overlay inode whether the real
inode is upper or lower.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---

Miklos,

This is a correctness fix.
I only noticed it because may_write_real() change broke xfstest generic/158.
The test tries to dedupe a directory, expects EINVAL and gets EPERM on
overlayfs instead.

I am not sure if there are cases where this incorrectness could lead to
EPERM when directory is upper and operation on dir should succeed.

Amir.


 fs/namespace.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/namespace.c b/fs/namespace.c
index 54059b142d6b..3b601f115b6c 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -468,7 +468,9 @@ static inline int may_write_real(struct file *file)
 
 	/* File refers to upper, writable layer? */
 	upperdentry = d_real(dentry, NULL, 0, D_REAL_UPPER);
-	if (upperdentry && file_inode(file) == d_inode(upperdentry))
+	if (upperdentry &&
+	    (file_inode(file) == d_inode(upperdentry) ||
+	     file_inode(file) == d_inode(dentry)))
 		return 0;
 
 	/* Lower layer: can't write to real file, sorry... */
-- 
2.7.4

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-09-18 20:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-18 20:21 [PATCH] vfs: fix may_write_real() for overlayfs directories Amir Goldstein

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).