• Amir Goldstein's avatar
    ovl: set i_ino to the value of st_ino for NFS export · 695b46e7
    Amir Goldstein authored
    Eddie Horng reported that readdir of an overlayfs directory that
    was exported via NFSv3 returns entries with d_type set to DT_UNKNOWN.
    The reason is that while preparing the response for readdirplus, nfsd
    checks inside encode_entryplus_baggage() that a child dentry's inode
    number matches the value of d_ino returns by overlayfs readdir iterator.
    
    Because the overlayfs inodes use arbitrary inode numbers that are not
    correlated with the values of st_ino/d_ino, NFSv3 falls back to not
    encoding d_type. Although this is an allowed behavior, we can fix it for
    the case of all overlayfs layers on the same underlying filesystem.
    
    When NFS export is enabled and d_ino is consistent with st_ino
    (samefs), set the same value also to i_ino in ovl_fill_inode() for all
    overlayfs inodes, nfsd readdirplus sanity checks will pass.
    ovl_fill_inode() may be called from ovl_new_inode(), before real inode
    was created with ino arg 0. In that case, i_ino will be updated to real
    upper inode i_ino on ovl_inode_init() or ovl_inode_update().
    Reported-by: default avatarEddie Horng <eddiehorng.tw@gmail.com>
    Tested-by: default avatarEddie Horng <eddiehorng.tw@gmail.com>
    Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
    Fixes: 8383f174 ("ovl: wire up NFS export operations")
    Cc: <stable@vger.kernel.org> #v4.16
    Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
    695b46e7
inode.c 20.5 KB