aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/notify/fanotify/fanotify_user.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index 9163a6ed67d2..3fdc8a3e1134 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -25,6 +25,19 @@
25#define FANOTIFY_DEFAULT_MAX_MARKS 8192 25#define FANOTIFY_DEFAULT_MAX_MARKS 8192
26#define FANOTIFY_DEFAULT_MAX_LISTENERS 128 26#define FANOTIFY_DEFAULT_MAX_LISTENERS 128
27 27
28/*
29 * All flags that may be specified in parameter event_f_flags of fanotify_init.
30 *
31 * Internal and external open flags are stored together in field f_flags of
32 * struct file. Only external open flags shall be allowed in event_f_flags.
33 * Internal flags like FMODE_NONOTIFY, FMODE_EXEC, FMODE_NOCMTIME shall be
34 * excluded.
35 */
36#define FANOTIFY_INIT_ALL_EVENT_F_BITS ( \
37 O_ACCMODE | O_APPEND | O_NONBLOCK | \
38 __O_SYNC | O_DSYNC | O_CLOEXEC | \
39 O_LARGEFILE | O_NOATIME )
40
28extern const struct fsnotify_ops fanotify_fsnotify_ops; 41extern const struct fsnotify_ops fanotify_fsnotify_ops;
29 42
30static struct kmem_cache *fanotify_mark_cache __read_mostly; 43static struct kmem_cache *fanotify_mark_cache __read_mostly;
@@ -669,6 +682,18 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags)
669 if (flags & ~FAN_ALL_INIT_FLAGS) 682 if (flags & ~FAN_ALL_INIT_FLAGS)
670 return -EINVAL; 683 return -EINVAL;
671 684
685 if (event_f_flags & ~FANOTIFY_INIT_ALL_EVENT_F_BITS)
686 return -EINVAL;
687
688 switch (event_f_flags & O_ACCMODE) {
689 case O_RDONLY:
690 case O_RDWR:
691 case O_WRONLY:
692 break;
693 default:
694 return -EINVAL;
695 }
696
672 user = get_current_user(); 697 user = get_current_user();
673 if (atomic_read(&user->fanotify_listeners) > FANOTIFY_DEFAULT_MAX_LISTENERS) { 698 if (atomic_read(&user->fanotify_listeners) > FANOTIFY_DEFAULT_MAX_LISTENERS) {
674 free_uid(user); 699 free_uid(user);