Tetsuo Handa f53823c181 bdi: Fix use after free bug in debugfs_remove()
syzbot is reporting use after free bug in debugfs_remove() [1].

This is because fault injection made memory allocation for
debugfs_create_file() from bdi_debug_register() from bdi_register_va()
fail and continued with setting WB_registered. But when debugfs_remove()
is called from debugfs_remove(bdi->debug_dir) from bdi_debug_unregister()
 from bdi_unregister() from release_bdi() because WB_registered was set
by bdi_register_va(), IS_ERR_OR_NULL(bdi->debug_dir) == false despite
debugfs_remove(bdi->debug_dir) was already called from bdi_register_va().

Fix this by making IS_ERR_OR_NULL(bdi->debug_dir) == true.

[1] https://syzkaller.appspot.com/bug?id=5ab4efd91a96dcea9b68104f159adf4af2a6dfc1

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Reported-by: syzbot <syzbot+049cb4ae097049dac137@syzkaller.appspotmail.com>
Fixes: 97f07697932e6faf ("bdi: convert bdi_debug_register to int")
Cc: weiping zhang <zhangweiping@didichuxing.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2018-05-03 09:36:24 -06:00
..
2017-06-05 16:59:12 +02:00
2018-04-11 10:28:32 -07:00
2017-02-27 18:43:47 -08:00
2018-04-13 17:10:27 -07:00
2018-04-11 10:28:32 -07:00
2017-11-15 18:21:05 -08:00
2018-04-11 10:28:39 -07:00
2018-04-07 12:08:19 -07:00
2018-04-11 10:28:32 -07:00
2018-04-11 10:28:32 -07:00
2018-04-11 10:28:38 -07:00
2018-04-20 17:18:35 -07:00
2018-04-11 10:28:39 -07:00
2018-04-20 17:18:35 -07:00
2018-04-11 10:28:39 -07:00
2017-11-15 18:21:01 -08:00
2018-04-11 10:28:39 -07:00
2018-04-11 10:28:39 -07:00
2018-04-13 17:10:27 -07:00
2018-04-11 10:28:39 -07:00
2018-02-06 18:32:48 -08:00