aboutsummaryrefslogtreecommitdiffstats
path: root/fs/notify
diff options
context:
space:
mode:
Diffstat (limited to 'fs/notify')
-rw-r--r--fs/notify/fanotify/fanotify.h25
-rw-r--r--fs/notify/fanotify/fanotify_user.c25
2 files changed, 10 insertions, 40 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
7extern const struct fsnotify_ops fanotify_fsnotify_ops; 7extern const struct fsnotify_ops fanotify_fsnotify_ops;
8 8
9static 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
27static inline bool fanotify_mask_valid(__u32 mask)
28{
29 if (mask & ~((__u32)FAN_ALL_INCOMING_EVENTS))
30 return false;
31 return true;
32}
33
34static inline __u32 fanotify_outgoing_mask(__u32 mask) 9static 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
433static 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 */
448SYSCALL_DEFINE3(fanotify_init, unsigned int, flags, unsigned int, event_f_flags, 434SYSCALL_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);