Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1493422
| From | Anton Altaparmakov <anton@tuxera.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Race condition between iget_locked() and evict_inodes() |
| Date | 2016-09-29 14:00 +0200 |
| Message-ID | <smIal-3Db-1@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
Hi Al, I think there is a race condition between iget_locked() and evict_inodes(). evict_inodes() checks i_count and if zero proceeds to take i_lock then set I_FREEING and eventually disposes of the inode. But a concurrent iget_locked() takes i_lock and then increments i_count. Thus if the events happen in this order: evict_inodes() iget_locked() in find_inode_fast() atomic_read(&inode->i_count) -> 0 take i_lock wait on i_lock __iget(inode); -> i_count now 1 set I_FREEING drop i_lock evict() return inode to caller The inode is now gone due to the evict() call whilst it is happily being used with an elevated i_count by the iget_locked() calling process. It seems to me like evict_inodes() should be checking i_count inside i_lock either as the only check or it should at least re-check it. Please tell me what I am missing here. I assume there must be something providing exclusion and I am just too blind to see it but I thought it worth bringing to your attention in case it really is simply broken. Best regards, Anton -- Anton Altaparmakov <anton at tuxera.com> (replace at with @) Lead in File System Development, Tuxera Inc., http://www.tuxera.com/ Linux NTFS maintainer
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
Race condition between iget_locked() and evict_inodes() Anton Altaparmakov <anton@tuxera.com> - 2016-09-29 14:00 +0200
Re: Race condition between iget_locked() and evict_inodes() Al Viro <viro@ZenIV.linux.org.uk> - 2016-09-29 14:20 +0200
Re: Race condition between iget_locked() and evict_inodes() Anton Altaparmakov <anton@tuxera.com> - 2016-09-29 15:00 +0200
Re: Race condition between iget_locked() and evict_inodes() Al Viro <viro@ZenIV.linux.org.uk> - 2016-09-29 15:40 +0200
csiph-web