ublk: Limit dev_id/ub_number values
authorMike Christie <michael.christie@oracle.com>
Thu, 12 Oct 2023 15:05:59 +0000 (10:05 -0500)
committerJens Axboe <axboe@kernel.dk>
Tue, 17 Oct 2023 14:27:24 +0000 (08:27 -0600)
commit56974c07f2c77d302fc311b0c6b95f45be76a3ae
tree666bc36eacf54488d18e783e17bba23fdac0e312
parentd451fdd0fe8323bf970b735cf276d4e11ae8cdcc
ublk: Limit dev_id/ub_number values

The dev_id/ub_number is used for the ublk dev's char device's minor
number so it has to fit into MINORMASK. This patch adds checks to prevent
userspace from passing a number that's too large and limits what can be
allocated by the ublk_index_idr for the case where userspace has the
kernel allocate the dev_id/ub_number.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20231012150600.6198-2-michael.christie@oracle.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/ublk_drv.c