Skip to contentSkip to conversation

tcmu: check if dev is configured before block/reset

PATCH Applied Mike Christie 1 participant 1 message Jul 23, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 5/9 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.

---
 drivers/target/target_core_user.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/target/target_core_user.c +10 -0
index bc8121f..d6b4022 100644
@@ -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;
Signature · 1 line
1.8.3.1