diff options
author | Zhao Hongjiang <zhaohongjiang@huawei.com> | 2013-04-30 18:26:46 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-30 20:04:00 -0400 |
commit | 04df32fa10ab9a6f0643db2949d42efc966bc844 (patch) | |
tree | 48cdb596da6d4b8bd49c743b570b63b936eba34f /fs/notify/inotify/inotify_user.c | |
parent | ace6128d603d3f15238baba104d0b37ccf0b6c07 (diff) |
inotify: invalid mask should return a error number but not set it
When we run the crackerjack testsuite, the inotify_add_watch test is
stalled.
This is caused by the invalid mask 0 - the task is waiting for the event
but it never comes. inotify_add_watch() should return -EINVAL as it did
before commit 676a0675cf92 ("inotify: remove broken mask checks causing
unmount to be EINVAL"). That commit removes the invalid mask check, but
that check is needed.
Check the mask's ALL_INOTIFY_BITS before the inotify_arg_to_mask() call.
If none are set, just return -EINVAL.
Because IN_UNMOUNT is in ALL_INOTIFY_BITS, this change will not trigger
the problem that above commit fixed.
[akpm@linux-foundation.org: fix build]
Signed-off-by: Zhao Hongjiang <zhaohongjiang@huawei.com>
Acked-by: Jim Somerville <Jim.Somerville@windriver.com>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Jerome Marchand <jmarchan@redhat.com>
Cc: Eric Paris <eparis@parisplace.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/notify/inotify/inotify_user.c')
-rw-r--r-- | fs/notify/inotify/inotify_user.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c index 8562bd3af947..c616a70e8cf9 100644 --- a/fs/notify/inotify/inotify_user.c +++ b/fs/notify/inotify/inotify_user.c | |||
@@ -570,7 +570,6 @@ static int inotify_update_existing_watch(struct fsnotify_group *group, | |||
570 | int add = (arg & IN_MASK_ADD); | 570 | int add = (arg & IN_MASK_ADD); |
571 | int ret; | 571 | int ret; |
572 | 572 | ||
573 | /* don't allow invalid bits: we don't want flags set */ | ||
574 | mask = inotify_arg_to_mask(arg); | 573 | mask = inotify_arg_to_mask(arg); |
575 | 574 | ||
576 | fsn_mark = fsnotify_find_inode_mark(group, inode); | 575 | fsn_mark = fsnotify_find_inode_mark(group, inode); |
@@ -621,7 +620,6 @@ static int inotify_new_watch(struct fsnotify_group *group, | |||
621 | struct idr *idr = &group->inotify_data.idr; | 620 | struct idr *idr = &group->inotify_data.idr; |
622 | spinlock_t *idr_lock = &group->inotify_data.idr_lock; | 621 | spinlock_t *idr_lock = &group->inotify_data.idr_lock; |
623 | 622 | ||
624 | /* don't allow invalid bits: we don't want flags set */ | ||
625 | mask = inotify_arg_to_mask(arg); | 623 | mask = inotify_arg_to_mask(arg); |
626 | 624 | ||
627 | tmp_i_mark = kmem_cache_alloc(inotify_inode_mark_cachep, GFP_KERNEL); | 625 | tmp_i_mark = kmem_cache_alloc(inotify_inode_mark_cachep, GFP_KERNEL); |
@@ -747,6 +745,10 @@ SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname, | |||
747 | int ret; | 745 | int ret; |
748 | unsigned flags = 0; | 746 | unsigned flags = 0; |
749 | 747 | ||
748 | /* don't allow invalid bits: we don't want flags set */ | ||
749 | if (unlikely(!(mask & ALL_INOTIFY_BITS))) | ||
750 | return -EINVAL; | ||
751 | |||
750 | f = fdget(fd); | 752 | f = fdget(fd); |
751 | if (unlikely(!f.file)) | 753 | if (unlikely(!f.file)) |
752 | return -EBADF; | 754 | return -EBADF; |