]> git.itanic.dy.fi Git - linux-stable/commitdiff
target: Fix lookup of dynamic NodeACLs during cached demo-mode operation
authorNicholas Bellinger <nab@linux-iscsi.org>
Tue, 19 Feb 2013 02:00:33 +0000 (18:00 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 3 Mar 2013 22:06:39 +0000 (06:06 +0800)
commit fcf29481fb8e106daad6688f2e898226ee928992 upstream.

This patch fixes a bug in core_tpg_check_initiator_node_acl() ->
core_tpg_get_initiator_node_acl() where a dynamically created
se_node_acl generated during session login would be skipped during
subsequent lookup due to the '!acl->dynamic_node_acl' check, causing
a new se_node_acl to be created with a duplicate ->initiatorname.

This would occur when a fabric endpoint was configured with
TFO->tpg_check_demo_mode()=1 + TPF->tpg_check_demo_mode_cache()=1
preventing the release of an existing se_node_acl during se_session
shutdown.

Also, drop the unnecessary usage of core_tpg_get_initiator_node_acl()
within core_dev_init_initiator_node_lun_acl() that originally
required the extra '!acl->dynamic_node_acl' check, and just pass
the configfs provided se_node_acl pointer instead.

Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/target/target_core_device.c
drivers/target/target_core_fabric_configfs.c
drivers/target/target_core_internal.h
drivers/target/target_core_tpg.c

index 4ecf9d61c22103ddf5b1f60ad68e5dce6c7995cb..79d9865a1270fa4f6288f545a0f4f428cbf1af81 100644 (file)
@@ -1483,24 +1483,18 @@ static struct se_lun *core_dev_get_lun(struct se_portal_group *tpg, u32 unpacked
 
 struct se_lun_acl *core_dev_init_initiator_node_lun_acl(
        struct se_portal_group *tpg,
+       struct se_node_acl *nacl,
        u32 mapped_lun,
-       char *initiatorname,
        int *ret)
 {
        struct se_lun_acl *lacl;
-       struct se_node_acl *nacl;
 
-       if (strlen(initiatorname) >= TRANSPORT_IQN_LEN) {
+       if (strlen(nacl->initiatorname) >= TRANSPORT_IQN_LEN) {
                pr_err("%s InitiatorName exceeds maximum size.\n",
                        tpg->se_tpg_tfo->get_fabric_name());
                *ret = -EOVERFLOW;
                return NULL;
        }
-       nacl = core_tpg_get_initiator_node_acl(tpg, initiatorname);
-       if (!nacl) {
-               *ret = -EINVAL;
-               return NULL;
-       }
        lacl = kzalloc(sizeof(struct se_lun_acl), GFP_KERNEL);
        if (!lacl) {
                pr_err("Unable to allocate memory for struct se_lun_acl.\n");
@@ -1511,7 +1505,8 @@ struct se_lun_acl *core_dev_init_initiator_node_lun_acl(
        INIT_LIST_HEAD(&lacl->lacl_list);
        lacl->mapped_lun = mapped_lun;
        lacl->se_lun_nacl = nacl;
-       snprintf(lacl->initiatorname, TRANSPORT_IQN_LEN, "%s", initiatorname);
+       snprintf(lacl->initiatorname, TRANSPORT_IQN_LEN, "%s",
+                nacl->initiatorname);
 
        return lacl;
 }
index 817ba7c849e7334d6229c0eb7065bc58867082de..1516bda3f759752339da57dab58dd1042f4c4214 100644 (file)
@@ -357,8 +357,8 @@ static struct config_group *target_fabric_make_mappedlun(
                goto out;
        }
 
-       lacl = core_dev_init_initiator_node_lun_acl(se_tpg, mapped_lun,
-                       config_item_name(acl_ci), &ret);
+       lacl = core_dev_init_initiator_node_lun_acl(se_tpg, se_nacl,
+                       mapped_lun, &ret);
        if (!lacl) {
                ret = -EINVAL;
                goto out;
index 21c05638f1587dc5328ccca291bf94553ebc1ec8..17179b1af540335a00422887bd7e65b655d6f76d 100644 (file)
@@ -61,7 +61,7 @@ struct se_lun *core_dev_add_lun(struct se_portal_group *, struct se_hba *,
 int    core_dev_del_lun(struct se_portal_group *, u32);
 struct se_lun *core_get_lun_from_tpg(struct se_portal_group *, u32);
 struct se_lun_acl *core_dev_init_initiator_node_lun_acl(struct se_portal_group *,
-               u32, char *, int *);
+               struct se_node_acl *, u32, int *);
 int    core_dev_add_initiator_node_lun_acl(struct se_portal_group *,
                struct se_lun_acl *, u32, u32);
 int    core_dev_del_initiator_node_lun_acl(struct se_portal_group *,
index ba537b6fd85eb98aa8195f4299365f3e5a78c52c..0e17fa3da01b1eec3e573091f0b932828693232a 100644 (file)
@@ -114,16 +114,10 @@ struct se_node_acl *core_tpg_get_initiator_node_acl(
        struct se_node_acl *acl;
 
        spin_lock_irq(&tpg->acl_node_lock);
-       list_for_each_entry(acl, &tpg->acl_node_list, acl_list) {
-               if (!strcmp(acl->initiatorname, initiatorname) &&
-                   !acl->dynamic_node_acl) {
-                       spin_unlock_irq(&tpg->acl_node_lock);
-                       return acl;
-               }
-       }
+       acl = __core_tpg_get_initiator_node_acl(tpg, initiatorname);
        spin_unlock_irq(&tpg->acl_node_lock);
 
-       return NULL;
+       return acl;
 }
 
 /*     core_tpg_add_node_to_devs():