提交 c6c2bf05 编写于 作者: A Amir Goldstein 提交者: Xie XiuQi

ovl: do not generate duplicate fsnotify events for "fake" path

mainline inclusion
from mainline-v5.2-rc1
commit d989903058a8
category: bugfix
bugzilla: 16008
CVE: NA

-------------------------------------------------

Overlayfs "fake" path is used for stacked file operations on underlying
files.  Operations on files with "fake" path must not generate fsnotify
events with path data, because those events have already been generated at
overlayfs layer and because the reported event->fd for fanotify marks on
underlying inode/filesystem will have the wrong path (the overlayfs path).

Link: https://lore.kernel.org/linux-fsdevel/20190423065024.12695-1-jencce.kernel@gmail.com/Reported-by: NMurphy Zhou <jencce.kernel@gmail.com>
Fixes: d1d04ef8 ("ovl: stack file ops")
Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Nzhangyi (F) <yi.zhang@huawei.com>
Reviewed-by: Nyangerkun <yangerkun@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 0ffffabd
...@@ -29,10 +29,11 @@ static struct file *ovl_open_realfile(const struct file *file, ...@@ -29,10 +29,11 @@ static struct file *ovl_open_realfile(const struct file *file,
struct inode *inode = file_inode(file); struct inode *inode = file_inode(file);
struct file *realfile; struct file *realfile;
const struct cred *old_cred; const struct cred *old_cred;
int flags = file->f_flags | O_NOATIME | FMODE_NONOTIFY;
old_cred = ovl_override_creds(inode->i_sb); 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(&file->f_path, flags, realinode,
realinode, current_cred()); current_cred());
revert_creds(old_cred); revert_creds(old_cred);
pr_debug("open(%p[%pD2/%c], 0%o) -> (%p, 0%o)\n", pr_debug("open(%p[%pD2/%c], 0%o) -> (%p, 0%o)\n",
...@@ -50,7 +51,7 @@ static int ovl_change_flags(struct file *file, unsigned int flags) ...@@ -50,7 +51,7 @@ static int ovl_change_flags(struct file *file, unsigned int flags)
int err; int err;
/* No atime modificaton on underlying */ /* No atime modificaton on underlying */
flags |= O_NOATIME; flags |= O_NOATIME | FMODE_NONOTIFY;
/* If some flag changed that cannot be changed then something's amiss */ /* If some flag changed that cannot be changed then something's amiss */
if (WARN_ON((file->f_flags ^ flags) & ~OVL_SETFL_MASK)) if (WARN_ON((file->f_flags ^ flags) & ~OVL_SETFL_MASK))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册