Skip to content

Commit 07db5e2

Browse files
mudongliangakpm00
authored andcommitted
fs: hfsplus: fix UAF issue in hfsplus_put_super
The current hfsplus_put_super first calls hfs_btree_close on sbi->ext_tree, then invokes iput on sbi->hidden_dir, resulting in an use-after-free issue in hfsplus_release_folio. As shown in hfsplus_fill_super, the error handling code also calls iput before hfs_btree_close. To fix this error, we move all iput calls before hfsplus_btree_close. Note that this patch is tested on Syzbot. Link: https://lkml.kernel.org/r/[email protected] Reported-by: [email protected] Tested-by: Dongliang Mu <[email protected]> Signed-off-by: Dongliang Mu <[email protected]> Cc: Bart Van Assche <[email protected]> Cc: Jens Axboe <[email protected]> Cc: Muchun Song <[email protected]> Cc: Roman Gushchin <[email protected]> Cc: "Theodore Ts'o" <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent b905039 commit 07db5e2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/hfsplus/super.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,11 @@ static void hfsplus_put_super(struct super_block *sb)
295295
hfsplus_sync_fs(sb, 1);
296296
}
297297

298+
iput(sbi->alloc_file);
299+
iput(sbi->hidden_dir);
298300
hfs_btree_close(sbi->attr_tree);
299301
hfs_btree_close(sbi->cat_tree);
300302
hfs_btree_close(sbi->ext_tree);
301-
iput(sbi->alloc_file);
302-
iput(sbi->hidden_dir);
303303
kfree(sbi->s_vhdr_buf);
304304
kfree(sbi->s_backup_vhdr_buf);
305305
unload_nls(sbi->nls);

0 commit comments

Comments
 (0)