scsi: tcmu: do not set max_blocks if data_bitmap has been setup
authorMike Christie <mchristi@redhat.com>
Mon, 23 Jul 2018 19:07:49 +0000 (14:07 -0500)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 31 Jul 2018 03:17:53 +0000 (23:17 -0400)
commitc97840c84f5a4362a596a2751e9245a979377a16
tree84005dbdc1bd7fd4a7f0d9000e4f621a9e726fbb
parentdc335a995527fb1ee9ec5649162b22cd1ce728ee
scsi: tcmu: do not set max_blocks if data_bitmap has been setup

This patch prevents a bug where data_bitmap is allocated in
tcmu_configure_device, userspace changes the max_blocks setting, the device
is mapped to a LUN, then we try to access the data_bitmap based on the new
max_blocks limit which may now be out of range.

To prevent this, we just check if data_bitmap has been setup. If it has
then we fail the max_blocks update operation.

Signed-off-by: Mike Christie <mchristi@redhat.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/target/target_core_user.c