Xie Yongji
57a13a5b81
virtio-blk: Use blk_validate_block_size() to validate block size
The block layer can't support a block size larger than
page size yet. And a block size that's too small or
not a power of two won't work either. If a misconfigured
device presents an invalid block size in configuration space,
it will result in the kernel crash something like below:
[ 506.154324] BUG: kernel NULL pointer dereference, address: 0000000000000008
[ 506.160416] RIP: 0010:create_empty_buffers+0x24/0x100
[ 506.174302] Call Trace:
[ 506.174651] create_page_buffers+0x4d/0x60
[ 506.175207] block_read_full_page+0x50/0x380
[ 506.175798] ? __mod_lruvec_page_state+0x60/0xa0
[ 506.176412] ? __add_to_page_cache_locked+0x1b2/0x390
[ 506.177085] ? blkdev_direct_IO+0x4a0/0x4a0
[ 506.177644] ? scan_shadow_nodes+0x30/0x30
[ 506.178206] ? lru_cache_add+0x42/0x60
[ 506.178716] do_read_cache_page+0x695/0x740
[ 506.179278] ? read_part_sector+0xe0/0xe0
[ 506.179821] read_part_sector+0x36/0xe0
[ 506.180337] adfspart_check_ICS+0x32/0x320
[ 506.180890] ? snprintf+0x45/0x70
[ 506.181350] ? read_part_sector+0xe0/0xe0
[ 506.181906] bdev_disk_changed+0x229/0x5c0
[ 506.182483] blkdev_get_whole+0x6d/0x90
[ 506.183013] blkdev_get_by_dev+0x122/0x2d0
[ 506.183562] device_add_disk+0x39e/0x3c0
[ 506.184472] virtblk_probe+0x3f8/0x79b [virtio_blk]
[ 506.185461] virtio_dev_probe+0x15e/0x1d0 [virtio]
So let's use a block layer helper to validate the block size.
Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Link: https://lore.kernel.org/r/20211026144015.188-5-xieyongji@bytedance.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2021-10-27 14:15:54 -06:00
..
2021-10-16 08:45:46 -07:00
2021-09-14 09:02:13 +02:00
2021-10-14 12:22:47 +09:00
2021-10-17 17:17:28 -10:00
2021-09-01 08:44:42 -07:00
2021-10-27 14:15:54 -06:00
2021-08-19 17:08:31 +02:00
2021-10-17 17:17:28 -10:00
2021-09-12 11:44:58 -07:00
2021-10-13 11:44:42 -07:00
2021-09-03 11:11:54 -07:00
2021-09-21 17:53:54 +02:00
2021-09-17 12:05:04 -07:00
2021-09-07 12:38:59 -07:00
2021-09-24 15:58:41 +08:00
2021-09-09 11:48:27 -07:00
2021-09-09 11:39:57 -07:00
2021-09-08 11:50:26 -07:00
2021-09-09 11:07:47 -07:00
2021-09-07 12:42:21 +05:30
2021-10-14 11:46:03 +02:00
2021-09-11 09:47:33 -07:00
2021-10-17 17:30:49 -10:00
2021-09-27 14:00:41 -07:00
2021-10-06 13:04:04 +02:00
2021-10-18 06:17:01 -06:00
2021-09-27 10:00:43 +02:00
2021-09-15 17:18:56 -07:00
2021-10-02 05:14:11 -07:00
2021-09-14 09:03:16 +02:00
2021-10-04 21:56:20 +02:00
2021-10-17 17:10:00 -10:00
2021-09-27 14:49:49 -03:00
2021-10-17 16:57:06 -10:00
2021-09-13 15:49:55 +03:00
2021-10-13 21:28:44 +02:00
2021-09-27 17:38:49 +02:00
2021-09-22 14:44:25 +01:00
2021-10-09 13:42:51 +01:00
2021-08-20 11:00:08 +02:00
2021-09-14 13:23:22 -07:00
2021-08-31 22:57:45 -05:00
2021-09-14 11:22:26 +02:00
2021-10-21 10:49:32 -06:00
2021-10-08 11:57:54 -07:00
2021-09-01 08:44:42 -07:00
2021-09-07 12:38:59 -07:00
2021-10-15 10:54:02 +02:00
2021-10-21 10:49:32 -06:00
2021-10-18 06:17:01 -06:00
2021-10-14 18:21:39 -04:00
2021-09-23 12:53:06 +01:00
2021-09-07 13:05:02 -07:00
2021-10-18 06:17:36 -06:00
2021-10-19 18:27:58 -06:00
2021-10-13 15:09:58 +02:00
2021-10-06 11:12:28 +02:00
2021-08-30 19:25:42 +02:00
2021-09-09 12:44:31 +02:00
2021-09-02 13:16:00 -07:00
2021-10-16 09:00:46 -07:00
2021-09-20 12:43:34 +01:00
2021-09-08 12:55:35 -07:00
2021-10-08 11:57:54 -07:00
2021-10-11 16:39:25 +02:00
2021-08-30 11:47:32 -07:00
2021-08-25 20:12:16 +02:00
2021-10-07 09:50:31 -07:00
2021-09-02 22:27:46 +02:00
2021-09-17 13:16:38 +01:00
2021-09-01 15:25:28 -07:00
2021-09-14 10:20:19 +02:00
2021-10-18 06:17:36 -06:00
2021-10-21 10:49:32 -06:00
2021-09-01 08:44:42 -07:00
2021-10-17 17:17:28 -10:00
2021-09-01 10:29:29 -07:00
2021-10-14 13:32:19 +01:00
2021-10-17 17:10:00 -10:00
2021-10-18 06:17:02 -06:00
2021-10-12 13:24:39 +02:00
2021-09-21 15:17:11 +02:00
2021-10-06 17:53:49 -06:00
2021-10-17 17:06:31 -10:00
2021-10-15 15:04:02 +02:00
2021-09-14 18:10:43 -04:00
2021-09-23 14:12:36 -06:00
2021-10-17 18:17:19 -10:00
2021-10-06 11:12:28 +02:00
2021-10-13 08:35:36 -04:00
2021-09-27 11:57:19 -07:00
2021-10-08 12:55:23 -07:00
2021-10-07 16:51:26 +02:00
2021-08-14 15:54:09 -06:00