]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
target: Add missing mapped_lun bounds checking during make_mappedlun setup
authorNicholas Bellinger <nab@linux-iscsi.org>
Tue, 19 Feb 2013 02:31:37 +0000 (18:31 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 3 Mar 2013 22:06:39 +0000 (06:06 +0800)
commit fbbf8555a986ed31e54f006b6cc637ea4ff1425b upstream.

This patch adds missing bounds checking for the configfs provided
mapped_lun value during target_fabric_make_mappedlun() setup ahead
of se_lun_acl initialization.

This addresses a potential OOPs when using a mapped_lun value that
exceeds the hardcoded TRANSPORT_MAX_LUNS_PER_TPG-1 value within
se_node_acl->device_list[].

Reported-by: Jan Engelhardt <jengelh@inai.de>
Cc: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/target/target_core_fabric_configfs.c

index 1516bda3f759752339da57dab58dd1042f4c4214..6b79ee7115257f3ff9107457d021274c8cd455ec 100644 (file)
@@ -356,6 +356,14 @@ static struct config_group *target_fabric_make_mappedlun(
                ret = -EINVAL;
                goto out;
        }
+       if (mapped_lun > (TRANSPORT_MAX_LUNS_PER_TPG-1)) {
+               pr_err("Mapped LUN: %lu exceeds TRANSPORT_MAX_LUNS_PER_TPG"
+                       "-1: %u for Target Portal Group: %u\n", mapped_lun,
+                       TRANSPORT_MAX_LUNS_PER_TPG-1,
+                       se_tpg->se_tpg_tfo->tpg_get_tag(se_tpg));
+               ret = -EINVAL;
+               goto out;
+       }
 
        lacl = core_dev_init_initiator_node_lun_acl(se_tpg, se_nacl,
                        mapped_lun, &ret);