Li Lingfeng 327462725b nbd: fix uaf in nbd_open
Commit 4af5f2e03013 ("nbd: use blk_mq_alloc_disk and
blk_cleanup_disk") cleans up disk by blk_cleanup_disk() and it won't set
disk->private_data as NULL as before. UAF may be triggered in nbd_open()
if someone tries to open nbd device right after nbd_put() since nbd has
been free in nbd_dev_remove().

Fix this by implementing ->free_disk and free private data in it.

Fixes: 4af5f2e03013 ("nbd: use blk_mq_alloc_disk and blk_cleanup_disk")
Signed-off-by: Li Lingfeng <lilingfeng3@huawei.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Link: https://lore.kernel.org/r/20231107103435.2074904-1-lilingfeng@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2023-11-07 08:14:57 -07:00
..
2023-10-03 18:23:48 -06:00
2023-10-30 19:09:55 -10:00
2023-08-28 11:04:18 -07:00
2023-01-04 14:44:13 -07:00
2022-06-28 06:33:15 -06:00
2023-11-07 08:14:57 -07:00
2022-06-28 06:33:15 -06:00
2023-01-29 15:18:35 -07:00
2023-08-10 08:32:59 -06:00
2023-06-26 12:47:20 -07:00