ovl: fix may_write_real() for overlayfs directories
authorAmir Goldstein <amir73il@gmail.com>
Mon, 18 Sep 2017 19:53:43 +0000 (22:53 +0300)
committerMiklos Szeredi <mszeredi@redhat.com>
Thu, 5 Oct 2017 13:53:18 +0000 (15:53 +0200)
Overlayfs directory file_inode() is the overlay inode whether the real
inode is upper or lower.

This fixes a regression in xfstest generic/158.

Fixes: 7c6893e3c9ab ("ovl: don't allow writing ioctl on lower layer")
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/namespace.c

index 54059b142d6ba1153b8adab7114cd7587e0c3aad..3b601f115b6cb72a9f02a82f5e8a41c458729b4b 100644 (file)
@@ -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... */