4f911d6
Bugzilla: 696821
4f911d6
Upstream-status: Sent http://marc.info/?l=linux-kernel&m=139835974112096&w=2
4f911d6
4f911d6
On 64-bit systems, O_LARGEFILE is automatically added to flags inside
4f911d6
the open() syscall (also openat(), blkdev_open(), etc).
4f911d6
Userspace therefore defines O_LARGEFILE to be 0 - you can use it,
4f911d6
but it's a no-op. Everything should be O_LARGEFILE by default.
4f911d6
4f911d6
But: when fanotify does create_fd() it uses dentry_open(), which skips
4f911d6
all that. And userspace can't set O_LARGEFILE in fanotify_init() because
4f911d6
it's defined to 0. So if fanotify gets an event regarding a large file,
4f911d6
the read() will just fail with -EOVERFLOW.
4f911d6
4f911d6
This patch adds O_LARGEFILE to fanotify_init()'s event_f_flags on 64-bit
4f911d6
systems, using the same test as open()/openat()/etc.
4f911d6
4f911d6
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=696821
4f911d6
4f911d6
Acked-by: Eric Paris <eparis@redhat.com>
4f911d6
Signed-off-by: Will Woods <wwoods@redhat.com>
4f911d6
---
4f911d6
 fs/notify/fanotify/fanotify_user.c | 2 ++
4f911d6
 1 file changed, 2 insertions(+)
4f911d6
4f911d6
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
4f911d6
index 4e565c8..732648b 100644
4f911d6
--- a/fs/notify/fanotify/fanotify_user.c
4f911d6
+++ b/fs/notify/fanotify/fanotify_user.c
4f911d6
@@ -698,6 +698,8 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags)
4f911d6
 	}
4f911d6
 	group->overflow_event = &oevent->fse;
4f911d6
 
4f911d6
+	if (force_o_largefile())
4f911d6
+		event_f_flags |= O_LARGEFILE;
4f911d6
 	group->fanotify_data.f_flags = event_f_flags;
4f911d6
 #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
4f911d6
 	spin_lock_init(&group->fanotify_data.access_lock);
4f911d6
-- 
4f911d6
1.9.0