mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-28 04:45:43 +01:00
scsi: target: iscsi: Fix race in discovery auth updates
Separate configfs opens can concurrently update the discovery AuthMethod
parameter. Both callers may free the same value in
iscsi_update_param_value(), causing a double-free.
Protect the lookup and replacement with the discovery TPG access lock,
as used by the other TPG configfs parameter updates.
Fixes: e48354ce07 ("iscsi-target: Add iSCSI fabric support for target v4.1")
Signed-off-by: Linfeng Sun <[email protected]>
Reviewed-by: Mike Christie <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Martin K. Petersen (Oracle) <[email protected]>
This commit is contained in:
1 parent
04a67a8b1a
commit
e15b81f602
1 file changed
+19
-7
@@ -1306,17 +1306,24 @@ static ssize_t iscsi_disc_enforce_discovery_auth_store(struct config_item *item,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (iscsit_get_tpg(discovery_tpg) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
param = iscsi_find_param_from_key(AUTHMETHOD,
|
||||
discovery_tpg->param_list);
|
||||
if (!param)
|
||||
return -EINVAL;
|
||||
if (!param) {
|
||||
err = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (op) {
|
||||
/*
|
||||
* Reset the AuthMethod key to CHAP.
|
||||
*/
|
||||
if (iscsi_update_param_value(param, CHAP) < 0)
|
||||
return -EINVAL;
|
||||
if (iscsi_update_param_value(param, CHAP) < 0) {
|
||||
err = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
discovery_tpg->tpg_attrib.authentication = 1;
|
||||
iscsit_global->discovery_acl.node_auth.enforce_discovery_auth = 1;
|
||||
@@ -1327,8 +1334,10 @@ static ssize_t iscsi_disc_enforce_discovery_auth_store(struct config_item *item,
|
||||
/*
|
||||
* Reset the AuthMethod key to CHAP,None
|
||||
*/
|
||||
if (iscsi_update_param_value(param, "CHAP,None") < 0)
|
||||
return -EINVAL;
|
||||
if (iscsi_update_param_value(param, "CHAP,None") < 0) {
|
||||
err = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
discovery_tpg->tpg_attrib.authentication = 0;
|
||||
iscsit_global->discovery_acl.node_auth.enforce_discovery_auth = 0;
|
||||
@@ -1337,7 +1346,10 @@ static ssize_t iscsi_disc_enforce_discovery_auth_store(struct config_item *item,
|
||||
" Discovery TPG\n");
|
||||
}
|
||||
|
||||
return count;
|
||||
err = count;
|
||||
out:
|
||||
iscsit_put_tpg(discovery_tpg);
|
||||
return err;
|
||||
}
|
||||
|
||||
CONFIGFS_ATTR(iscsi_disc_, enforce_discovery_auth);
|
||||
|
||||
Reference in new issue
Block a user