Skip to content

Commit

Permalink
ovl: fix may_write_real() for overlayfs directories
Browse files Browse the repository at this point in the history
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: 7c6893e ("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>
  • Loading branch information
Amir Goldstein authored and Miklos Szeredi committed Oct 5, 2017
1 parent 9e66317 commit 954c736
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fs/namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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... */
Expand Down

0 comments on commit 954c736

Please sign in to comment.