Thanks for writing and reviewing that code. I looked at inotify.c after the patch was applied and found a few races and integer-overflow issues, most of which have likely been lurking there for a while. I fixed the problems that I found by installing the attached patch into master; please give it a try when you have the time.