diff options
-rw-r--r-- | fs/notify/fanotify/fanotify.h | 25 | ||||
-rw-r--r-- | fs/notify/fanotify/fanotify_user.c | 25 | ||||
-rw-r--r-- | include/linux/fanotify.h | 7 |
3 files changed, 10 insertions, 47 deletions
diff --git a/fs/notify/fanotify/fanotify.h b/fs/notify/fanotify/fanotify.h index 5608783c6bca..4d5723a74a8e 100644 --- a/fs/notify/fanotify/fanotify.h +++ b/fs/notify/fanotify/fanotify.h | |||
@@ -6,31 +6,6 @@ | |||
6 | 6 | ||
7 | extern const struct fsnotify_ops fanotify_fsnotify_ops; | 7 | extern const struct fsnotify_ops fanotify_fsnotify_ops; |
8 | 8 | ||
9 | static inline bool fanotify_mark_flags_valid(unsigned int flags) | ||
10 | { | ||
11 | /* must be either and add or a remove */ | ||
12 | if (!(flags & (FAN_MARK_ADD | FAN_MARK_REMOVE))) | ||
13 | return false; | ||
14 | |||
15 | /* cannot be both add and remove */ | ||
16 | if ((flags & FAN_MARK_ADD) && | ||
17 | (flags & FAN_MARK_REMOVE)) | ||
18 | return false; | ||
19 | |||
20 | /* cannot have more flags than we know about */ | ||
21 | if (flags & ~FAN_ALL_MARK_FLAGS) | ||
22 | return false; | ||
23 | |||
24 | return true; | ||
25 | } | ||
26 | |||
27 | static inline bool fanotify_mask_valid(__u32 mask) | ||
28 | { | ||
29 | if (mask & ~((__u32)FAN_ALL_INCOMING_EVENTS)) | ||
30 | return false; | ||
31 | return true; | ||
32 | } | ||
33 | |||
34 | static inline __u32 fanotify_outgoing_mask(__u32 mask) | 9 | static inline __u32 fanotify_outgoing_mask(__u32 mask) |
35 | { | 10 | { |
36 | return mask & FAN_ALL_OUTGOING_EVENTS; | 11 | return mask & FAN_ALL_OUTGOING_EVENTS; |
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index 00628d3ce5a2..618867e4d30f 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c | |||
@@ -430,20 +430,6 @@ static int fanotify_add_inode_mark(struct fsnotify_group *group, | |||
430 | return 0; | 430 | return 0; |
431 | } | 431 | } |
432 | 432 | ||
433 | static bool fanotify_mark_validate_input(int flags, | ||
434 | __u32 mask) | ||
435 | { | ||
436 | pr_debug("%s: flags=%x mask=%x\n", __func__, flags, mask); | ||
437 | |||
438 | /* are flags valid of this operation? */ | ||
439 | if (!fanotify_mark_flags_valid(flags)) | ||
440 | return false; | ||
441 | /* is the mask valid? */ | ||
442 | if (!fanotify_mask_valid(mask)) | ||
443 | return false; | ||
444 | return true; | ||
445 | } | ||
446 | |||
447 | /* fanotify syscalls */ | 433 | /* fanotify syscalls */ |
448 | SYSCALL_DEFINE3(fanotify_init, unsigned int, flags, unsigned int, event_f_flags, | 434 | SYSCALL_DEFINE3(fanotify_init, unsigned int, flags, unsigned int, event_f_flags, |
449 | unsigned int, priority) | 435 | unsigned int, priority) |
@@ -505,7 +491,16 @@ SYSCALL_DEFINE(fanotify_mark)(int fanotify_fd, unsigned int flags, | |||
505 | if (mask & ((__u64)0xffffffff << 32)) | 491 | if (mask & ((__u64)0xffffffff << 32)) |
506 | return -EINVAL; | 492 | return -EINVAL; |
507 | 493 | ||
508 | if (!fanotify_mark_validate_input(flags, mask)) | 494 | if (flags & ~FAN_ALL_MARK_FLAGS) |
495 | return -EINVAL; | ||
496 | switch (flags & (FAN_MARK_ADD | FAN_MARK_REMOVE)) { | ||
497 | case FAN_MARK_ADD: | ||
498 | case FAN_MARK_REMOVE: | ||
499 | break; | ||
500 | default: | ||
501 | return -EINVAL; | ||
502 | } | ||
503 | if (mask & ~(FAN_ALL_EVENTS | FAN_EVENT_ON_CHILD)) | ||
509 | return -EINVAL; | 504 | return -EINVAL; |
510 | 505 | ||
511 | filp = fget_light(fanotify_fd, &fput_needed); | 506 | filp = fget_light(fanotify_fd, &fput_needed); |
diff --git a/include/linux/fanotify.h b/include/linux/fanotify.h index 5ee22fb274e5..90e59b24fd04 100644 --- a/include/linux/fanotify.h +++ b/include/linux/fanotify.h | |||
@@ -47,13 +47,6 @@ | |||
47 | FAN_CLOSE |\ | 47 | FAN_CLOSE |\ |
48 | FAN_OPEN) | 48 | FAN_OPEN) |
49 | 49 | ||
50 | /* | ||
51 | * All legal FAN bits userspace can request (although possibly not all | ||
52 | * at the same time. | ||
53 | */ | ||
54 | #define FAN_ALL_INCOMING_EVENTS (FAN_ALL_EVENTS |\ | ||
55 | FAN_EVENT_ON_CHILD) | ||
56 | |||
57 | #define FAN_ALL_OUTGOING_EVENTS (FAN_ALL_EVENTS |\ | 50 | #define FAN_ALL_OUTGOING_EVENTS (FAN_ALL_EVENTS |\ |
58 | FAN_Q_OVERFLOW) | 51 | FAN_Q_OVERFLOW) |
59 | 52 | ||