ovl: verify upper dentry before unlink and rename
authorMiklos Szeredi <mszeredi@redhat.com>
Mon, 21 Mar 2016 16:31:44 +0000 (17:31 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Jul 2016 16:47:40 +0000 (09:47 -0700)
commitdbf72a4d4531e7e5fb28e76d902d66f05c1bfe12
treec19301388d1a4349958bb8a67fe6f081fe409e38
parent38da63ef2c131593ff89372048c14cd8bd1fe4b4
ovl: verify upper dentry before unlink and rename

commit 11f3710417d026ea2f4fcf362d866342c5274185 upstream.

Unlink and rename in overlayfs checked the upper dentry for staleness by
verifying upper->d_parent against upperdir.  However the dentry can go
stale also by being unhashed, for example.

Expand the verification to actually look up the name again (under parent
lock) and check if it matches the upper dentry.  This matches what the VFS
does before passing the dentry to filesytem's unlink/rename methods, which
excludes any inconsistency caused by overlayfs.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/overlayfs/dir.c