|
@@ -706,7 +706,19 @@ SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname,
|
|
int ret;
|
|
int ret;
|
|
unsigned flags = 0;
|
|
unsigned flags = 0;
|
|
|
|
|
|
- /* don't allow invalid bits: we don't want flags set */
|
|
|
|
|
|
+ /*
|
|
|
|
+ * We share a lot of code with fs/dnotify. We also share
|
|
|
|
+ * the bit layout between inotify's IN_* and the fsnotify
|
|
|
|
+ * FS_*. This check ensures that only the inotify IN_*
|
|
|
|
+ * bits get passed in and set in watches/events.
|
|
|
|
+ */
|
|
|
|
+ if (unlikely(mask & ~ALL_INOTIFY_BITS))
|
|
|
|
+ return -EINVAL;
|
|
|
|
+ /*
|
|
|
|
+ * Require at least one valid bit set in the mask.
|
|
|
|
+ * Without _something_ set, we would have no events to
|
|
|
|
+ * watch for.
|
|
|
|
+ */
|
|
if (unlikely(!(mask & ALL_INOTIFY_BITS)))
|
|
if (unlikely(!(mask & ALL_INOTIFY_BITS)))
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
|
|
|