107655b
Bugzilla: 696821
107655b
Upstream-status: Sent http://marc.info/?l=linux-kernel&m=139835974112096&w=2
107655b
107655b
On 64-bit systems, O_LARGEFILE is automatically added to flags inside
107655b
the open() syscall (also openat(), blkdev_open(), etc).
107655b
Userspace therefore defines O_LARGEFILE to be 0 - you can use it,
107655b
but it's a no-op. Everything should be O_LARGEFILE by default.
107655b
107655b
But: when fanotify does create_fd() it uses dentry_open(), which skips
107655b
all that. And userspace can't set O_LARGEFILE in fanotify_init() because
107655b
it's defined to 0. So if fanotify gets an event regarding a large file,
107655b
the read() will just fail with -EOVERFLOW.
107655b
107655b
This patch adds O_LARGEFILE to fanotify_init()'s event_f_flags on 64-bit
107655b
systems, using the same test as open()/openat()/etc.
107655b
107655b
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=696821
107655b
107655b
Acked-by: Eric Paris <eparis@redhat.com>
107655b
Signed-off-by: Will Woods <wwoods@redhat.com>
107655b
107655b
--- linux-3.14.1-200.fc20.x86_64/fs/notify/fanotify/fanotify_user.c.orig	2014-04-23 18:15:29.347644932 -0400
107655b
+++ linux-3.14.1-200.fc20.x86_64/fs/notify/fanotify/fanotify_user.c	2014-04-23 18:17:44.249438484 -0400
107655b
@@ -742,6 +742,8 @@
107655b
 	oevent->path.mnt = NULL;
107655b
 	oevent->path.dentry = NULL;
107655b
 
107655b
+	if (force_o_largefile())
107655b
+		event_f_flags |= O_LARGEFILE;
107655b
 	group->fanotify_data.f_flags = event_f_flags;
107655b
 #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
107655b
 	oevent->response = 0;