• Miklos Szeredi's avatar
    vfs: rename: check backing inode being equal · 8e5bb3c5
    Miklos Szeredi authored
    commit 9409e22a upstream.
    
    If a file is renamed to a hardlink of itself POSIX specifies that rename(2)
    should do nothing and return success.
    
    This condition is checked in vfs_rename().  However it won't detect hard
    links on overlayfs where these are given separate inodes on the overlayfs
    layer.
    
    Overlayfs itself detects this condition and returns success without doing
    anything, but then vfs_rename() will proceed as if this was a successful
    rename (detach_mounts(), d_move()).
    
    The correct thing to do is to detect this condition before even calling
    into overlayfs.  This patch does this by calling vfs_select_inode() to get
    the underlying inodes.
    Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    8e5bb3c5
namei.c 115 KB