Messages in this thread | | | Date | Tue, 22 Jul 2014 14:04:18 +0400 | From | Andrey Tsyvarev <> | Subject | Re: f2fs: Possible use-after-free when umount filesystem |
| |
Hi Gu,
>> Investigation shows, that f2fs_evict_inode, when called for 'meta_inode', uses invalidate_mapping_pages() for 'node_inode'. >> But 'node_inode' is deleted before 'meta_inode' in f2fs_put_super via iput(). >> >> It seems that in common usage scenario this use-after-free is benign, because 'node_inode' remains partially valid data even after kmem_cache_free(). >> But things may change if, while 'meta_inode' is evicted in one f2fs filesystem, another (mounted) f2fs filesystem requests inode from cache, and formely >> 'node_inode' of the first filesystem is returned. > The analysis seems reasonable. Have you tried to swap the reclaim order of node_inde > and meta_inode? > > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c > index 870fe19..e114418 100644 > --- a/fs/f2fs/super.c > +++ b/fs/f2fs/super.c > @@ -430,8 +430,8 @@ static void f2fs_put_super(struct super_block *sb) > if (sbi->s_dirty && get_pages(sbi, F2FS_DIRTY_NODES)) > write_checkpoint(sbi, true); > > - iput(sbi->node_inode); > iput(sbi->meta_inode); > + iput(sbi->node_inode); > > /* destroy f2fs internal modules */ > destroy_node_manager(sbi); > > Thanks, > Gu
With reclaim order of node_inode and meta_inode swapped, use-after-free error disappears.
But shouldn't initialization order of these inodes be swapped too? As meta_inode uses node_inode, it seems logical that it should be initialized after it.
-- Best regards,
Andrey Tsyvarev Linux Verification Center, ISPRAS web:http://linuxtesting.org
| |