summaryrefslogtreecommitdiff
path: root/fs/open.c
diff options
context:
space:
mode:
authorEric Paris <eparis@redhat.com>2009-11-12 18:51:30 -0500
committerEric Paris <eparis@redhat.com>2009-11-12 18:52:08 -0500
commit4952589a3f6499d2767fdf1b045d831d6e797451 (patch)
treed0ce5d4efad6051c8211ddf5efd3d6d1ae12b190 /fs/open.c
parentd1aa01854fcc8d9a18b5f8c6157598e4d424b9bf (diff)
vfs: introduce FMODE_NONOTIFY
This is a new f_mode which can only be set by the kernel. It indicates that the fd was opened by fanotify and should not cause future fanotify events. This is needed to prevent fanotify livelock. An example of obvious livelock is from fanotify close events. Process A closes file1 This creates a close event for file1. fanotify opens file1 for Listener X Listener X deals with the event and closes its fd for file1. This creates a close event for file1. fanotify opens file1 for Listener X Listener X deals with the event and closes its fd for file1. This creates a close event for file1. fanotify opens file1 for Listener X Listener X deals with the event and closes its fd for file1. notice a pattern? The fix is to add the FMODE_NONOTIFY bit to the open filp done by the kernel for fanotify. Thus when that file is used it will not generate future events. This patch simply defines the bit. Signed-off-by: Eric Paris <eparis@redhat.com>
Diffstat (limited to 'fs/open.c')
-rw-r--r--fs/open.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/fs/open.c b/fs/open.c
index c064e7be15e5..365352ce1f54 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -812,9 +812,10 @@ static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
struct inode *inode;
int error;
- f->f_flags = flags;
- f->f_mode = (__force fmode_t)((flags+1) & O_ACCMODE) | FMODE_LSEEK |
- FMODE_PREAD | FMODE_PWRITE;
+ f->f_flags = (flags & ~(FMODE_EXEC | FMODE_NONOTIFY));
+ f->f_mode = (__force fmode_t)((flags+1) & O_ACCMODE) | (flags & FMODE_NONOTIFY) |
+ FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE;
+
inode = dentry->d_inode;
if (f->f_mode & FMODE_WRITE) {
error = __get_file_write_access(inode, mnt);