]> git.baikalelectronics.ru Git - kernel.git/commit
ovl: use inode_insert5() to hash a newly created inode
authorAmir Goldstein <amir73il@gmail.com>
Fri, 11 May 2018 08:15:15 +0000 (11:15 +0300)
committerMiklos Szeredi <mszeredi@redhat.com>
Thu, 31 May 2018 09:06:12 +0000 (11:06 +0200)
commit7491cf7e54d00568f81ee93f644490f8a7768644
tree18675377623d5ef108a90a72a9b523cf535e4210
parentd95626ba31f36db954e63d67a69e44ac16504156
ovl: use inode_insert5() to hash a newly created inode

Currently, there is a small window where ovl_obtain_alias() can
race with ovl_instantiate() and create two different overlay inodes
with the same underlying real non-dir non-hardlink inode.

The race requires an adversary to guess the file handle of the
yet to be created upper inode and decode the guessed file handle
after ovl_creat_real(), but before ovl_instantiate().
This race does not affect overlay directory inodes, because those
are decoded via ovl_lookup_real() and not with ovl_obtain_alias().

This patch fixes the race, by using inode_insert5() to add a newly
created inode to cache.

If the newly created inode apears to already exist in cache (hashed
by the same real upper inode), we instantiate the dentry with the old
inode and drop the new inode, instead of silently not hashing the new
inode.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/overlayfs/dir.c
fs/overlayfs/inode.c
fs/overlayfs/overlayfs.h