Skip to content

Commit 300b124

Browse files
amir73ilMiklos Szeredi
authored andcommitted
ovl: fix value of i_ino for lower hardlink corner case
Commit 6dde1e4 ("ovl: make i_ino consistent with st_ino in more cases"), relaxed the condition nfs_export=on in order to set the value of i_ino to xino map of real ino. Specifically, it also relaxed the pre-condition that index=on for consistent i_ino. This opened the corner case of lower hardlink in ovl_get_inode(), which calls ovl_fill_inode() with ino=0 and then ovl_init_inode() is called to set i_ino to lower real ino without the xino mapping. Pass the correct values of ino;fsid in this case to ovl_fill_inode(), so it can initialize i_ino correctly. Fixes: 6dde1e4 ("ovl: make i_ino consistent with st_ino in more ...") Signed-off-by: Amir Goldstein <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]>
1 parent fb33c65 commit 300b124

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/overlayfs/inode.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ struct inode *ovl_get_inode(struct super_block *sb,
891891
struct dentry *lowerdentry = lowerpath ? lowerpath->dentry : NULL;
892892
bool bylower = ovl_hash_bylower(sb, upperdentry, lowerdentry,
893893
oip->index);
894-
int fsid = bylower ? oip->lowerpath->layer->fsid : 0;
894+
int fsid = bylower ? lowerpath->layer->fsid : 0;
895895
bool is_dir, metacopy = false;
896896
unsigned long ino = 0;
897897
int err = oip->newinode ? -EEXIST : -ENOMEM;
@@ -941,6 +941,8 @@ struct inode *ovl_get_inode(struct super_block *sb,
941941
err = -ENOMEM;
942942
goto out_err;
943943
}
944+
ino = realinode->i_ino;
945+
fsid = lowerpath->layer->fsid;
944946
}
945947
ovl_fill_inode(inode, realinode->i_mode, realinode->i_rdev, ino, fsid);
946948
ovl_inode_init(inode, upperdentry, lowerdentry, oip->lowerdata);

0 commit comments

Comments
 (0)