]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/ovl-do-not-generate-duplicate-fsnotify-events-for-fa.patch
Linux 5.1.10
[thirdparty/kernel/stable-queue.git] / queue-4.19 / ovl-do-not-generate-duplicate-fsnotify-events-for-fa.patch
1 From 20778975512f338e21884e5174289ae1d265b8fe Mon Sep 17 00:00:00 2001
2 From: Amir Goldstein <amir73il@gmail.com>
3 Date: Wed, 24 Apr 2019 19:39:50 +0300
4 Subject: ovl: do not generate duplicate fsnotify events for "fake" path
5
6 [ Upstream commit d989903058a83e8536cc7aadf9256a47d5c173fe ]
7
8 Overlayfs "fake" path is used for stacked file operations on underlying
9 files. Operations on files with "fake" path must not generate fsnotify
10 events with path data, because those events have already been generated at
11 overlayfs layer and because the reported event->fd for fanotify marks on
12 underlying inode/filesystem will have the wrong path (the overlayfs path).
13
14 Link: https://lore.kernel.org/linux-fsdevel/20190423065024.12695-1-jencce.kernel@gmail.com/
15 Reported-by: Murphy Zhou <jencce.kernel@gmail.com>
16 Fixes: d1d04ef8572b ("ovl: stack file ops")
17 Signed-off-by: Amir Goldstein <amir73il@gmail.com>
18 Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
19 Signed-off-by: Sasha Levin <sashal@kernel.org>
20 ---
21 fs/overlayfs/file.c | 7 ++++---
22 1 file changed, 4 insertions(+), 3 deletions(-)
23
24 diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
25 index 0c810f20f778..2c993937b784 100644
26 --- a/fs/overlayfs/file.c
27 +++ b/fs/overlayfs/file.c
28 @@ -29,10 +29,11 @@ static struct file *ovl_open_realfile(const struct file *file,
29 struct inode *inode = file_inode(file);
30 struct file *realfile;
31 const struct cred *old_cred;
32 + int flags = file->f_flags | O_NOATIME | FMODE_NONOTIFY;
33
34 old_cred = ovl_override_creds(inode->i_sb);
35 - realfile = open_with_fake_path(&file->f_path, file->f_flags | O_NOATIME,
36 - realinode, current_cred());
37 + realfile = open_with_fake_path(&file->f_path, flags, realinode,
38 + current_cred());
39 revert_creds(old_cred);
40
41 pr_debug("open(%p[%pD2/%c], 0%o) -> (%p, 0%o)\n",
42 @@ -50,7 +51,7 @@ static int ovl_change_flags(struct file *file, unsigned int flags)
43 int err;
44
45 /* No atime modificaton on underlying */
46 - flags |= O_NOATIME;
47 + flags |= O_NOATIME | FMODE_NONOTIFY;
48
49 /* If some flag changed that cannot be changed then something's amiss */
50 if (WARN_ON((file->f_flags ^ flags) & ~OVL_SETFL_MASK))
51 --
52 2.20.1
53