[PATCH Trusty SRU] fanotify: fix -EOVERFLOW with large files on 64-bit
tim.gardner at canonical.com
tim.gardner at canonical.com
Fri Dec 18 12:59:49 UTC 2015
From: Will Woods <wwoods at redhat.com>
BugLink: http://bugs.launchpad.net/bugs/1527039
On 64-bit systems, O_LARGEFILE is automatically added to flags inside
the open() syscall (also openat(), blkdev_open(), etc). Userspace
therefore defines O_LARGEFILE to be 0 - you can use it, but it's a
no-op. Everything should be O_LARGEFILE by default.
But: when fanotify does create_fd() it uses dentry_open(), which skips
all that. And userspace can't set O_LARGEFILE in fanotify_init()
because it's defined to 0. So if fanotify gets an event regarding a
large file, the read() will just fail with -EOVERFLOW.
This patch adds O_LARGEFILE to fanotify_init()'s event_f_flags on 64-bit
systems, using the same test as open()/openat()/etc.
Addresses https://bugzilla.redhat.com/show_bug.cgi?id=696821
Signed-off-by: Will Woods <wwoods at redhat.com>
Acked-by: Eric Paris <eparis at redhat.com>
Reviewed-by: Jan Kara <jack at suse.cz>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
(back ported from commit 1e2ee49f7f1b79f0b14884fe6a602f0411b39552)
Signed-off-by: Tim Gardner <tim.gardner at canonical.com>
---
fs/notify/fanotify/fanotify_user.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index cc80b0a..864bd62 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -727,6 +727,8 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags)
group->fanotify_data.user = user;
atomic_inc(&user->fanotify_listeners);
+ if (force_o_largefile())
+ event_f_flags |= O_LARGEFILE;
group->fanotify_data.f_flags = event_f_flags;
#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
mutex_init(&group->fanotify_data.access_mutex);
--
1.9.1
More information about the kernel-team
mailing list