• Miklos Szeredi's avatar
    vfs_rename_dir() doesn't properly account for filesystems with · 920a06de
    Miklos Szeredi authored
    FS_RENAME_DOES_D_MOVE.  If new_dentry has a target inode attached, it
    unhashes the new_dentry prior to the rename() iop and rehashes it after,
    but doesn't account for the possibility that rename() may have swapped
    {old,new}_dentry.  For FS_RENAME_DOES_D_MOVE filesystems, it rehashes
    new_dentry (now the old renamed-from name, which d_move() expected to go
    away), such that a subsequent lookup will find it.
    
    This was caught by the recently posted POSIX fstest suite, rename/10.t
    test 62 (and others) on ceph.
    
    The bug was introduced by: commit 349457cc
    "[PATCH] Allow file systems to manually d_move() inside of ->rename()"
    
    Fix by not rehashing the new dentry.  Rehashing used to be needed by
    d_move() but isn't anymore.
    Reported-by: default avatarSage Weil <sage@newdream.net>
    Cc: Zach Brown <zach.brown@oracle.com>
    Signed-off-by: default avatarMiklos Szeredi <mszeredi@suse.cz>
    Cc: Mark Fasheh <mark.fasheh@oracle.com>
    Cc: Trond Myklebust <trond.myklebust@fys.uio.no>
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Cc: Christoph Hellwig <hch@lst.de>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    920a06de
namei.c 71.3 KB