aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorZhao Hongjiang2013-04-30 17:26:46 -0500
committerGreg Kroah-Hartman2013-05-07 22:08:22 -0500
commitdd644cc9dae03d05c128ee3aba39d18b97ebdc22 (patch)
treedc3a0ec51c4752f01c5373ec2dbf3c7b9d65a66d /fs
parent4f452a14022af59bdc1b28732b3680731ec481c8 (diff)
downloadkernel-omap-dd644cc9dae03d05c128ee3aba39d18b97ebdc22.tar.gz
kernel-omap-dd644cc9dae03d05c128ee3aba39d18b97ebdc22.tar.xz
kernel-omap-dd644cc9dae03d05c128ee3aba39d18b97ebdc22.zip
inotify: invalid mask should return a error number but not set it
commit 04df32fa10ab9a6f0643db2949d42efc966bc844 upstream. 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> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/notify/inotify/inotify_user.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index 07f7a92fe88e..595343ee24c6 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -574,7 +574,6 @@ static int inotify_update_existing_watch(struct fsnotify_group *group,
574 int add = (arg & IN_MASK_ADD); 574 int add = (arg & IN_MASK_ADD);
575 int ret; 575 int ret;
576 576
577 /* don't allow invalid bits: we don't want flags set */
578 mask = inotify_arg_to_mask(arg); 577 mask = inotify_arg_to_mask(arg);
579 578
580 fsn_mark = fsnotify_find_inode_mark(group, inode); 579 fsn_mark = fsnotify_find_inode_mark(group, inode);
@@ -625,7 +624,6 @@ static int inotify_new_watch(struct fsnotify_group *group,
625 struct idr *idr = &group->inotify_data.idr; 624 struct idr *idr = &group->inotify_data.idr;
626 spinlock_t *idr_lock = &group->inotify_data.idr_lock; 625 spinlock_t *idr_lock = &group->inotify_data.idr_lock;
627 626
628 /* don't allow invalid bits: we don't want flags set */
629 mask = inotify_arg_to_mask(arg); 627 mask = inotify_arg_to_mask(arg);
630 628
631 tmp_i_mark = kmem_cache_alloc(inotify_inode_mark_cachep, GFP_KERNEL); 629 tmp_i_mark = kmem_cache_alloc(inotify_inode_mark_cachep, GFP_KERNEL);
@@ -753,6 +751,10 @@ SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname,
753 int ret; 751 int ret;
754 unsigned flags = 0; 752 unsigned flags = 0;
755 753
754 /* don't allow invalid bits: we don't want flags set */
755 if (unlikely(!(mask & ALL_INOTIFY_BITS)))
756 return -EINVAL;
757
756 f = fdget(fd); 758 f = fdget(fd);
757 if (unlikely(!f.file)) 759 if (unlikely(!f.file))
758 return -EBADF; 760 return -EBADF;