diff options
author | Robert Love <rml@novell.com> | 2005-07-25 15:10:08 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-07-26 13:37:21 -0700 |
commit | 783bc29bbc5d6625a4669d3eb1d989a8fb275d43 (patch) | |
tree | 100222921c788e68009ba1b2dccbeaba06b81e89 /fs | |
parent | 33ea2f52b8758ef62ae4a9d2f91821c47d999ee9 (diff) | |
download | linux-3.10-783bc29bbc5d6625a4669d3eb1d989a8fb275d43.tar.gz linux-3.10-783bc29bbc5d6625a4669d3eb1d989a8fb275d43.tar.bz2 linux-3.10-783bc29bbc5d6625a4669d3eb1d989a8fb275d43.zip |
[PATCH] inotify: oops fix
Bug fix: Ensure that the fd passed to inotify_add_watch() and
inotify_rm_watch() belongs to inotify.
Signed-off-by: Robert Love <rml@novell.com>
Signed-off-by: John McCutchan <ttb@tentacle.dhs.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/inotify.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/fs/inotify.c b/fs/inotify.c index 807209f0bcd..b55d6e4a091 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) if (unlikely(!filp)) return -EBADF; + /* verify that this is indeed an inotify instance */ + if (unlikely(filp->f_op != &inotify_fops)) { + ret = -EINVAL; + goto fput_and_out; + } + ret = find_inode(path, &nd); if (unlikely(ret)) goto fput_and_out; @@ -986,10 +992,18 @@ asmlinkage long sys_inotify_rm_watch(int fd, u32 wd) filp = fget_light(fd, &fput_needed); if (unlikely(!filp)) return -EBADF; + + /* verify that this is indeed an inotify instance */ + if (unlikely(filp->f_op != &inotify_fops)) { + ret = -EINVAL; + goto out; + } + dev = filp->private_data; ret = inotify_ignore(dev, wd); - fput_light(filp, fput_needed); +out: + fput_light(filp, fput_needed); return ret; } |