ovl: fix may_write_real() for overlayfs directories

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: 7c6893e3c9 ("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>
This commit is contained in:
Amir Goldstein 2017-09-18 22:53:43 +03:00 committed by Miklos Szeredi
parent 9e66317d3c
commit 954c736f86
1 changed files with 3 additions and 1 deletions

View 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... */