]> git.baikalelectronics.ru Git - kernel.git/commit
fs: hfsplus: fix UAF issue in hfsplus_put_super
authorDongliang Mu <mudongliangabcd@gmail.com>
Sun, 26 Feb 2023 12:49:47 +0000 (20:49 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Mar 2023 08:34:07 +0000 (09:34 +0100)
commitc349f8e2c9d403fe58e5c8443e86bc3e3ae5175b
tree62ea749b03d7e4bcba7f11f2a441e25800cdbddc
parent43e0e524e01e7ac9dd454795c36bb9b89631e528
fs: hfsplus: fix UAF issue in hfsplus_put_super

commit 35c5af28fdc61b0f61790f69c1b4df52d8f62d90 upstream.

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/20230226124948.3175736-1-mudongliangabcd@gmail.com
Reported-by: syzbot+57e3e98f7e3b80f64d56@syzkaller.appspotmail.com
Tested-by: Dongliang Mu <mudongliangabcd@gmail.com>
Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Muchun Song <songmuchun@bytedance.com>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/hfsplus/super.c