linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] ovl: do not generate duplicate fsnotify events for "fake" path
@ 2019-04-24 16:39 Amir Goldstein
  2019-04-25  0:55 ` kbuild test robot
  2019-04-28  3:08 ` Murphy Zhou
  0 siblings, 2 replies; 4+ messages in thread
From: Amir Goldstein @ 2019-04-24 16:39 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: Jan Kara, Murphy Zhou, linux-fsdevel, linux-unionfs

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: Murphy Zhou <jencce.kernel@gmail.com>
Fixes: d1d04ef8572b ("ovl: stack file ops")
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---

Miklos,

V1 was addressed to Jan and was trying to teach fsnotify about fake path.
V2 leaves fsnotify subsystem alone and just sets the FMODE_NONOTIFY
flag on realfile. All the rest of the complications with mark mounts
are irrelevant.

Same extended fanotify06 that was used to verify V1 also verified V2.

Thanks,
Amir.

 fs/overlayfs/file.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
index ddfd93f13cc5..7d2f01957e40 100644
--- a/fs/overlayfs/file.c
+++ b/fs/overlayfs/file.c
@@ -29,10 +29,11 @@ static struct file *ovl_open_realfile(const struct file *file,
 	struct inode *inode = file_inode(file);
 	struct file *realfile;
 	const struct cred *old_cred;
+	int flags = file->f_flags | O_NOATIME | FMODE_NONOTIFY;
 
 	old_cred = ovl_override_creds(inode->i_sb);
-	realfile = open_with_fake_path(&file->f_path, file->f_flags | O_NOATIME,
-				       realinode, current_cred());
+	realfile = open_with_fake_path(&file->f_path, flags, realinode,
+				       current_cred());
 	revert_creds(old_cred);
 
 	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)
 	int err;
 
 	/* 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 (WARN_ON((file->f_flags ^ flags) & ~OVL_SETFL_MASK))
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-05-06 11:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-24 16:39 [PATCH v2] ovl: do not generate duplicate fsnotify events for "fake" path Amir Goldstein
2019-04-25  0:55 ` kbuild test robot
2019-04-28  3:08 ` Murphy Zhou
2019-05-06 11:58   ` Miklos Szeredi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).