Commit a30b0473 authored by Mike Christie's avatar Mike Christie Committed by Martin K. Petersen

scsi: tcmu: check if dev is configured before block/reset

Do not allow userspace to block or reset the ring until the device has been
configured. This will prevent the bug where userspace can write to those
files and access mb_addr before it has been setup.
Signed-off-by: default avatarMike Christie <mchristi@redhat.com>
Reviewed-by: default avatarXiubo Li <xiubli@redhat.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 63d5be0f
......@@ -2480,6 +2480,11 @@ static ssize_t tcmu_block_dev_store(struct config_item *item, const char *page,
u8 val;
int ret;
if (!target_dev_configured(&udev->se_dev)) {
pr_err("Device is not configured.\n");
return -EINVAL;
}
ret = kstrtou8(page, 0, &val);
if (ret < 0)
return ret;
......@@ -2507,6 +2512,11 @@ static ssize_t tcmu_reset_ring_store(struct config_item *item, const char *page,
u8 val;
int ret;
if (!target_dev_configured(&udev->se_dev)) {
pr_err("Device is not configured.\n");
return -EINVAL;
}
ret = kstrtou8(page, 0, &val);
if (ret < 0)
return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment