Skip to content

Commit

Permalink
[PATCH] inotify: oops fix
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Robert Love authored and Linus Torvalds committed Jul 26, 2005
1 parent 33ea2f5 commit 783bc29
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion fs/inotify.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 783bc29

Please sign in to comment.