aboutsummaryrefslogtreecommitdiffstats
path: root/fs/notify
diff options
context:
space:
mode:
Diffstat (limited to 'fs/notify')
-rw-r--r--fs/notify/fanotify/fanotify_user.c17
-rw-r--r--fs/notify/inotify/inotify_user.c14
2 files changed, 9 insertions, 22 deletions
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index 5d8444268a16..d0be29fa94cf 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -755,9 +755,9 @@ out_destroy_group:
755 return fd; 755 return fd;
756} 756}
757 757
758SYSCALL_DEFINE(fanotify_mark)(int fanotify_fd, unsigned int flags, 758SYSCALL_DEFINE5(fanotify_mark, int, fanotify_fd, unsigned int, flags,
759 __u64 mask, int dfd, 759 __u64, mask, int, dfd,
760 const char __user * pathname) 760 const char __user *, pathname)
761{ 761{
762 struct inode *inode = NULL; 762 struct inode *inode = NULL;
763 struct vfsmount *mnt = NULL; 763 struct vfsmount *mnt = NULL;
@@ -857,17 +857,6 @@ fput_and_out:
857 return ret; 857 return ret;
858} 858}
859 859
860#ifdef CONFIG_HAVE_SYSCALL_WRAPPERS
861asmlinkage long SyS_fanotify_mark(long fanotify_fd, long flags, __u64 mask,
862 long dfd, long pathname)
863{
864 return SYSC_fanotify_mark((int) fanotify_fd, (unsigned int) flags,
865 mask, (int) dfd,
866 (const char __user *) pathname);
867}
868SYSCALL_ALIAS(sys_fanotify_mark, SyS_fanotify_mark);
869#endif
870
871/* 860/*
872 * fanotify_user_setup - Our initialization function. Note that we cannot return 861 * fanotify_user_setup - Our initialization function. Note that we cannot return
873 * error because we have compiled-in VFS hooks. So an (unlikely) failure here 862 * error because we have compiled-in VFS hooks. So an (unlikely) failure here
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index 1db6d886cbf2..959815c1e017 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -356,7 +356,6 @@ static int inotify_find_inode(const char __user *dirname, struct path *path, uns
356} 356}
357 357
358static int inotify_add_to_idr(struct idr *idr, spinlock_t *idr_lock, 358static int inotify_add_to_idr(struct idr *idr, spinlock_t *idr_lock,
359 int *last_wd,
360 struct inotify_inode_mark *i_mark) 359 struct inotify_inode_mark *i_mark)
361{ 360{
362 int ret; 361 int ret;
@@ -364,11 +363,10 @@ static int inotify_add_to_idr(struct idr *idr, spinlock_t *idr_lock,
364 idr_preload(GFP_KERNEL); 363 idr_preload(GFP_KERNEL);
365 spin_lock(idr_lock); 364 spin_lock(idr_lock);
366 365
367 ret = idr_alloc(idr, i_mark, *last_wd + 1, 0, GFP_NOWAIT); 366 ret = idr_alloc_cyclic(idr, i_mark, 1, 0, GFP_NOWAIT);
368 if (ret >= 0) { 367 if (ret >= 0) {
369 /* we added the mark to the idr, take a reference */ 368 /* we added the mark to the idr, take a reference */
370 i_mark->wd = ret; 369 i_mark->wd = ret;
371 *last_wd = i_mark->wd;
372 fsnotify_get_mark(&i_mark->fsn_mark); 370 fsnotify_get_mark(&i_mark->fsn_mark);
373 } 371 }
374 372
@@ -569,7 +567,6 @@ static int inotify_update_existing_watch(struct fsnotify_group *group,
569 int add = (arg & IN_MASK_ADD); 567 int add = (arg & IN_MASK_ADD);
570 int ret; 568 int ret;
571 569
572 /* don't allow invalid bits: we don't want flags set */
573 mask = inotify_arg_to_mask(arg); 570 mask = inotify_arg_to_mask(arg);
574 571
575 fsn_mark = fsnotify_find_inode_mark(group, inode); 572 fsn_mark = fsnotify_find_inode_mark(group, inode);
@@ -620,7 +617,6 @@ static int inotify_new_watch(struct fsnotify_group *group,
620 struct idr *idr = &group->inotify_data.idr; 617 struct idr *idr = &group->inotify_data.idr;
621 spinlock_t *idr_lock = &group->inotify_data.idr_lock; 618 spinlock_t *idr_lock = &group->inotify_data.idr_lock;
622 619
623 /* don't allow invalid bits: we don't want flags set */
624 mask = inotify_arg_to_mask(arg); 620 mask = inotify_arg_to_mask(arg);
625 621
626 tmp_i_mark = kmem_cache_alloc(inotify_inode_mark_cachep, GFP_KERNEL); 622 tmp_i_mark = kmem_cache_alloc(inotify_inode_mark_cachep, GFP_KERNEL);
@@ -635,8 +631,7 @@ static int inotify_new_watch(struct fsnotify_group *group,
635 if (atomic_read(&group->inotify_data.user->inotify_watches) >= inotify_max_user_watches) 631 if (atomic_read(&group->inotify_data.user->inotify_watches) >= inotify_max_user_watches)
636 goto out_err; 632 goto out_err;
637 633
638 ret = inotify_add_to_idr(idr, idr_lock, &group->inotify_data.last_wd, 634 ret = inotify_add_to_idr(idr, idr_lock, tmp_i_mark);
639 tmp_i_mark);
640 if (ret) 635 if (ret)
641 goto out_err; 636 goto out_err;
642 637
@@ -694,7 +689,6 @@ static struct fsnotify_group *inotify_new_group(unsigned int max_events)
694 689
695 spin_lock_init(&group->inotify_data.idr_lock); 690 spin_lock_init(&group->inotify_data.idr_lock);
696 idr_init(&group->inotify_data.idr); 691 idr_init(&group->inotify_data.idr);
697 group->inotify_data.last_wd = 0;
698 group->inotify_data.user = get_current_user(); 692 group->inotify_data.user = get_current_user();
699 693
700 if (atomic_inc_return(&group->inotify_data.user->inotify_devs) > 694 if (atomic_inc_return(&group->inotify_data.user->inotify_devs) >
@@ -748,6 +742,10 @@ SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname,
748 int ret; 742 int ret;
749 unsigned flags = 0; 743 unsigned flags = 0;
750 744
745 /* don't allow invalid bits: we don't want flags set */
746 if (unlikely(!(mask & ALL_INOTIFY_BITS)))
747 return -EINVAL;
748
751 f = fdget(fd); 749 f = fdget(fd);
752 if (unlikely(!f.file)) 750 if (unlikely(!f.file))
753 return -EBADF; 751 return -EBADF;