aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/inotify.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/fs/inotify.c b/fs/inotify.c
index 807209f0bcda..b55d6e4a0911 100644
--- a/fs/inotify.c
+++ b/fs/inotify.c
@@ -929,6 +929,12 @@ asmlinkage long sys_inotify_add_watch(int fd, const char __user *path, u32 mask)
929 if (unlikely(!filp)) 929 if (unlikely(!filp))
930 return -EBADF; 930 return -EBADF;
931 931
932 /* verify that this is indeed an inotify instance */
933 if (unlikely(filp->f_op != &inotify_fops)) {
934 ret = -EINVAL;
935 goto fput_and_out;
936 }
937
932 ret = find_inode(path, &nd); 938 ret = find_inode(path, &nd);
933 if (unlikely(ret)) 939 if (unlikely(ret))
934 goto fput_and_out; 940 goto fput_and_out;
@@ -986,10 +992,18 @@ asmlinkage long sys_inotify_rm_watch(int fd, u32 wd)
986 filp = fget_light(fd, &fput_needed); 992 filp = fget_light(fd, &fput_needed);
987 if (unlikely(!filp)) 993 if (unlikely(!filp))
988 return -EBADF; 994 return -EBADF;
995
996 /* verify that this is indeed an inotify instance */
997 if (unlikely(filp->f_op != &inotify_fops)) {
998 ret = -EINVAL;
999 goto out;
1000 }
1001
989 dev = filp->private_data; 1002 dev = filp->private_data;
990 ret = inotify_ignore(dev, wd); 1003 ret = inotify_ignore(dev, wd);
991 fput_light(filp, fput_needed);
992 1004
1005out:
1006 fput_light(filp, fput_needed);
993 return ret; 1007 return ret;
994} 1008}
995 1009