block: ublk: make sure that block size is set correctly
authorMing Lei <ming.lei@redhat.com>
Thu, 6 Apr 2023 12:40:59 +0000 (20:40 +0800)
committerJens Axboe <axboe@kernel.dk>
Thu, 6 Apr 2023 14:12:08 +0000 (08:12 -0600)
commit1d1665279a845d16c93687389e364386e3fe0f38
tree33ed3df30e720842aa0b35e3ffa6aa157403faa5
parent8c68ae3b22fa6fb2dbe83ef955ff10936503d28e
block: ublk: make sure that block size is set correctly

block size is one very key setting for block layer, and bad block size
could panic kernel easily.

Make sure that block size is set correctly.

Meantime if ublk_validate_params() fails, clear ub->params so that disk
is prevented from being added.

Fixes: 71f28f3136af ("ublk_drv: add io_uring based userspace block driver")
Reported-and-tested-by: Breno Leitao <leitao@debian.org>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/ublk_drv.c