Skip to content

Commit 939ae4e

Browse files
amir73ilMiklos Szeredi
authored andcommitted
ovl: fix false positive ESTALE on lookup
Commit b9ac5c2 ("ovl: hash overlay non-dir inodes by copy up origin") verifies that the origin lower inode stored in the overlayfs inode matched the inode of a copy up origin dentry found by lookup. There is a false positive result in that check when lower fs does not support file handles and copy up origin cannot be followed by file handle at lookup time. The false negative happens when finding an overlay inode in cache on a copied up overlay dentry lookup. The overlay inode still 'remembers' the copy up origin inode, but the copy up origin dentry is not available for verification. Relax the check in case copy up origin dentry is not available. Fixes: b9ac5c2 ("ovl: hash overlay non-dir inodes by copy up...") Cc: <[email protected]> # v4.13 Reported-by: Jordi Pujol <[email protected]> Signed-off-by: Amir Goldstein <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]>
1 parent 7c6893e commit 939ae4e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

fs/overlayfs/inode.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -579,10 +579,13 @@ static int ovl_inode_set(struct inode *inode, void *data)
579579
static bool ovl_verify_inode(struct inode *inode, struct dentry *lowerdentry,
580580
struct dentry *upperdentry)
581581
{
582-
struct inode *lowerinode = lowerdentry ? d_inode(lowerdentry) : NULL;
583-
584-
/* Lower (origin) inode must match, even if NULL */
585-
if (ovl_inode_lower(inode) != lowerinode)
582+
/*
583+
* Allow non-NULL lower inode in ovl_inode even if lowerdentry is NULL.
584+
* This happens when finding a copied up overlay inode for a renamed
585+
* or hardlinked overlay dentry and lower dentry cannot be followed
586+
* by origin because lower fs does not support file handles.
587+
*/
588+
if (lowerdentry && ovl_inode_lower(inode) != d_inode(lowerdentry))
586589
return false;
587590

588591
/*

0 commit comments

Comments
 (0)