ovl: verify upper dentry in ovl_remove_and_whiteout()
authorMaxim Patlasov <mpatlasov@virtuozzo.com>
Fri, 22 Jul 2016 01:24:26 +0000 (18:24 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Jul 2016 16:47:39 +0000 (09:47 -0700)
commitcf2a2c6de0516f595825c9c46eb8ebc12a48dd31
tree680edeff8e90f2760313687bcf23f0cea9946cfc
parentc12dada5f28a4894b81df2666c060f5cecc02cf9
ovl: verify upper dentry in ovl_remove_and_whiteout()

commit cfc9fde0b07c3b44b570057c5f93dda59dca1c94 upstream.

The upper dentry may become stale before we call ovl_lock_rename_workdir.
For example, someone could (mistakenly or maliciously) manually unlink(2)
it directly from upperdir.

To ensure it is not stale, let's lookup it after ovl_lock_rename_workdir
and and check if it matches the upper dentry.

Essentially, it is the same problem and similar solution as in
commit 11f3710417d0 ("ovl: verify upper dentry before unlink and rename").

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