From c511a103ba6690cbf6748f25700cb8e95dd77982 Mon Sep 17 00:00:00 2001 From: Amir Goldstein Date: Tue, 23 Apr 2019 13:11:10 +0300 Subject: [PATCH] ovl: use real path for open_with_fake_path() ovl_open() uses open_with_fake_path() to create a file object with a given path. Currently overlayfs uses the overlay path as the "fake" path. This causes some issues when VFS code refers to file->f_path->mnt. One issue, reported by Murphy Zhou, is that fsnotify hooks check for mount marks against the wrong vfsmount. Link: https://lore.kernel.org/linux-fsdevel/20190423065024.12695-1-jencce.kernel@gmail.com/ Reported-by: Murphy Zhou Signed-off-by: Amir Goldstein --- fs/overlayfs/file.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index ddfd93f13cc5..ec9f8763fe08 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -28,10 +28,13 @@ static struct file *ovl_open_realfile(const struct file *file, { struct inode *inode = file_inode(file); struct file *realfile; + struct path realpath; const struct cred *old_cred; + ovl_path_real(file_dentry(file), &realpath); + old_cred = ovl_override_creds(inode->i_sb); - realfile = open_with_fake_path(&file->f_path, file->f_flags | O_NOATIME, + realfile = open_with_fake_path(&realpath, file->f_flags | O_NOATIME, realinode, current_cred()); revert_creds(old_cred); -- 2.17.1