2011-06-10 11:21:06

by OGAWA Hirofumi

[permalink] [raw]
Subject: Race inotify_rm_watch vs umount

Hi,

I'm looking the race inotify_rm_watch() vs umount(). This race become the
cause of Oops. You can see the oops at

https://bugzilla.kernel.org/show_bug.cgi?id=22602

So, what race?

umount inotify_rm_watch
... fsnotify_destroy_mark()
fsnotify_destroy_inode_mark()
/* removed from i_fsnotify_marks */
generic_shutdown_super()
fsnotify_unmount_inodes()
put_super()
iput()
iput_final()
/* this is after put_super() */

Like above, inotify doesn't guarantee to call final iput() before
put_super(). With this violation, FS driver can oops.

Well, so, what are requested for inotify? We can't simply take
sb->s_umount in inotify_rm_watch()?

Any ideas?

Thanks.
--
OGAWA Hirofumi <[email protected]>


2011-06-10 13:46:12

by Eric Paris

[permalink] [raw]
Subject: Re: Race inotify_rm_watch vs umount

On Fri, 2011-06-10 at 20:20 +0900, OGAWA Hirofumi wrote:
> Hi,
>
> I'm looking the race inotify_rm_watch() vs umount(). This race become the
> cause of Oops. You can see the oops at
>
> https://bugzilla.kernel.org/show_bug.cgi?id=22602
>
> So, what race?

Ok, I see what you are saying, I'll see what I can do. I'm a little
scared to call something like iput() under a lock though. I might be
able to make the bigest lock a mutex and fix this....

I'll add this to my test suite.

-Eric
>
> umount inotify_rm_watch
> ... fsnotify_destroy_mark()
> fsnotify_destroy_inode_mark()
> /* removed from i_fsnotify_marks */
> generic_shutdown_super()
> fsnotify_unmount_inodes()
> put_super()
> iput()
> iput_final()
> /* this is after put_super() */
>
> Like above, inotify doesn't guarantee to call final iput() before
> put_super(). With this violation, FS driver can oops.
>
> Well, so, what are requested for inotify? We can't simply take
> sb->s_umount in inotify_rm_watch()?
>
> Any ideas?
>
> Thanks.

2011-06-10 14:35:59

by Al Viro

[permalink] [raw]
Subject: Re: Race inotify_rm_watch vs umount

On Fri, Jun 10, 2011 at 09:46:05AM -0400, Eric Paris wrote:
> On Fri, 2011-06-10 at 20:20 +0900, OGAWA Hirofumi wrote:
> > Hi,
> >
> > I'm looking the race inotify_rm_watch() vs umount(). This race become the
> > cause of Oops. You can see the oops at
> >
> > https://bugzilla.kernel.org/show_bug.cgi?id=22602
> >
> > So, what race?
>
> Ok, I see what you are saying, I'll see what I can do. I'm a little
> scared to call something like iput() under a lock though. I might be
> able to make the bigest lock a mutex and fix this....

Which lock would that be? I don't see any good candidates in there...