]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
vfs: rename: check backing inode being equal
authorMiklos Szeredi <mszeredi@redhat.com>
Tue, 10 May 2016 23:16:37 +0000 (01:16 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 May 2016 00:06:49 +0000 (17:06 -0700)
commit8e5bb3c5417fd98c8966807dc07cc1b687da97c4
tree8a9a0ca98b24d73295568e541350b95f737531fb
parentb0dac61d2454b392dbdb4ad565f9dc3dc76fce96
vfs: rename: check backing inode being equal

commit 9409e22acdfc9153f88d9b1ed2bd2a5b34d2d3ca 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: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/namei.c