aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target/target_core_user.c
diff options
context:
space:
mode:
authorMike Christie <mchristi@redhat.com>2018-07-23 14:07:47 -0500
committerMartin K. Petersen <martin.petersen@oracle.com>2018-07-30 23:17:53 -0400
commita30b0473b62652f9b8ccb1e4f4a3a3c31d2b72b3 (patch)
tree9a45302ea322125bb5109a0c390931c1019ee600 /drivers/target/target_core_user.c
parentscsi: tcmu: use lio core se_device configuration helper (diff)
downloadlinux-dev-a30b0473b62652f9b8ccb1e4f4a3a3c31d2b72b3.tar.xz
linux-dev-a30b0473b62652f9b8ccb1e4f4a3a3c31d2b72b3.zip
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: Mike Christie <mchristi@redhat.com> Reviewed-by: Xiubo Li <xiubli@redhat.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/target/target_core_user.c')
-rw-r--r--drivers/target/target_core_user.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index bc8121f97d65..d6b402203b20 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -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;