X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=kernel%2Ffs%2Fnotify%2Finotify%2Finotify_user.c;h=b8d08d0d0a4dbe061b9336dd7f861d32e13c8618;hb=e09b41010ba33a20a87472ee821fa407a5b8da36;hp=4506486974336d6451abc0658de78c0c06bdec9a;hpb=9ca8dbcc65cfc63d6f5ef3312a33184e1d726e00;p=kvmfornfv.git diff --git a/kernel/fs/notify/inotify/inotify_user.c b/kernel/fs/notify/inotify/inotify_user.c index 450648697..b8d08d0d0 100644 --- a/kernel/fs/notify/inotify/inotify_user.c +++ b/kernel/fs/notify/inotify/inotify_user.c @@ -26,7 +26,7 @@ #include /* struct inode */ #include #include -#include /* module_init */ +#include /* fs_initcall */ #include #include /* roundup() */ #include /* LOOKUP_FOLLOW */ @@ -706,7 +706,19 @@ SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname, int ret; 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))) return -EINVAL; @@ -812,4 +824,4 @@ static int __init inotify_user_setup(void) return 0; } -module_init(inotify_user_setup); +fs_initcall(inotify_user_setup);