diff options
| -rw-r--r-- | drivers/target/iscsi/iscsi_target_configfs.c | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c index b41d4786fa08..684d73fcbedf 100644 --- a/drivers/target/iscsi/iscsi_target_configfs.c +++ b/drivers/target/iscsi/iscsi_target_configfs.c | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
| 21 | 21 | ||
| 22 | #include <linux/configfs.h> | 22 | #include <linux/configfs.h> |
| 23 | #include <linux/ctype.h> | ||
| 23 | #include <linux/export.h> | 24 | #include <linux/export.h> |
| 24 | #include <linux/inet.h> | 25 | #include <linux/inet.h> |
| 25 | #include <target/target_core_base.h> | 26 | #include <target/target_core_base.h> |
| @@ -78,11 +79,12 @@ static ssize_t lio_target_np_store_sctp( | |||
| 78 | struct iscsi_tpg_np *tpg_np = container_of(se_tpg_np, | 79 | struct iscsi_tpg_np *tpg_np = container_of(se_tpg_np, |
| 79 | struct iscsi_tpg_np, se_tpg_np); | 80 | struct iscsi_tpg_np, se_tpg_np); |
| 80 | struct iscsi_tpg_np *tpg_np_sctp = NULL; | 81 | struct iscsi_tpg_np *tpg_np_sctp = NULL; |
| 81 | char *endptr; | ||
| 82 | u32 op; | 82 | u32 op; |
| 83 | int ret; | 83 | int ret; |
| 84 | 84 | ||
| 85 | op = simple_strtoul(page, &endptr, 0); | 85 | ret = kstrtou32(page, 0, &op); |
| 86 | if (ret) | ||
| 87 | return ret; | ||
| 86 | if ((op != 1) && (op != 0)) { | 88 | if ((op != 1) && (op != 0)) { |
| 87 | pr_err("Illegal value for tpg_enable: %u\n", op); | 89 | pr_err("Illegal value for tpg_enable: %u\n", op); |
| 88 | return -EINVAL; | 90 | return -EINVAL; |
| @@ -381,11 +383,12 @@ static ssize_t iscsi_nacl_attrib_store_##name( \ | |||
| 381 | { \ | 383 | { \ |
| 382 | struct iscsi_node_acl *nacl = container_of(se_nacl, struct iscsi_node_acl, \ | 384 | struct iscsi_node_acl *nacl = container_of(se_nacl, struct iscsi_node_acl, \ |
| 383 | se_node_acl); \ | 385 | se_node_acl); \ |
| 384 | char *endptr; \ | ||
| 385 | u32 val; \ | 386 | u32 val; \ |
| 386 | int ret; \ | 387 | int ret; \ |
| 387 | \ | 388 | \ |
| 388 | val = simple_strtoul(page, &endptr, 0); \ | 389 | ret = kstrtou32(page, 0, &val); \ |
| 390 | if (ret) \ | ||
| 391 | return ret; \ | ||
| 389 | ret = iscsit_na_##name(nacl, val); \ | 392 | ret = iscsit_na_##name(nacl, val); \ |
| 390 | if (ret < 0) \ | 393 | if (ret < 0) \ |
| 391 | return ret; \ | 394 | return ret; \ |
| @@ -788,11 +791,12 @@ static ssize_t lio_target_nacl_store_cmdsn_depth( | |||
| 788 | struct iscsi_portal_group *tpg = container_of(se_tpg, | 791 | struct iscsi_portal_group *tpg = container_of(se_tpg, |
| 789 | struct iscsi_portal_group, tpg_se_tpg); | 792 | struct iscsi_portal_group, tpg_se_tpg); |
| 790 | struct config_item *acl_ci, *tpg_ci, *wwn_ci; | 793 | struct config_item *acl_ci, *tpg_ci, *wwn_ci; |
| 791 | char *endptr; | ||
| 792 | u32 cmdsn_depth = 0; | 794 | u32 cmdsn_depth = 0; |
| 793 | int ret; | 795 | int ret; |
| 794 | 796 | ||
| 795 | cmdsn_depth = simple_strtoul(page, &endptr, 0); | 797 | ret = kstrtou32(page, 0, &cmdsn_depth); |
| 798 | if (ret) | ||
| 799 | return ret; | ||
| 796 | if (cmdsn_depth > TA_DEFAULT_CMDSN_DEPTH_MAX) { | 800 | if (cmdsn_depth > TA_DEFAULT_CMDSN_DEPTH_MAX) { |
| 797 | pr_err("Passed cmdsn_depth: %u exceeds" | 801 | pr_err("Passed cmdsn_depth: %u exceeds" |
| 798 | " TA_DEFAULT_CMDSN_DEPTH_MAX: %u\n", cmdsn_depth, | 802 | " TA_DEFAULT_CMDSN_DEPTH_MAX: %u\n", cmdsn_depth, |
| @@ -976,14 +980,15 @@ static ssize_t iscsi_tpg_attrib_store_##name( \ | |||
| 976 | { \ | 980 | { \ |
| 977 | struct iscsi_portal_group *tpg = container_of(se_tpg, \ | 981 | struct iscsi_portal_group *tpg = container_of(se_tpg, \ |
| 978 | struct iscsi_portal_group, tpg_se_tpg); \ | 982 | struct iscsi_portal_group, tpg_se_tpg); \ |
| 979 | char *endptr; \ | ||
| 980 | u32 val; \ | 983 | u32 val; \ |
| 981 | int ret; \ | 984 | int ret; \ |
| 982 | \ | 985 | \ |
| 983 | if (iscsit_get_tpg(tpg) < 0) \ | 986 | if (iscsit_get_tpg(tpg) < 0) \ |
| 984 | return -EINVAL; \ | 987 | return -EINVAL; \ |
| 985 | \ | 988 | \ |
| 986 | val = simple_strtoul(page, &endptr, 0); \ | 989 | ret = kstrtou32(page, 0, &val); \ |
| 990 | if (ret) \ | ||
| 991 | goto out; \ | ||
| 987 | ret = iscsit_ta_##name(tpg, val); \ | 992 | ret = iscsit_ta_##name(tpg, val); \ |
| 988 | if (ret < 0) \ | 993 | if (ret < 0) \ |
| 989 | goto out; \ | 994 | goto out; \ |
| @@ -1211,13 +1216,14 @@ static ssize_t iscsi_tpg_param_store_##name( \ | |||
| 1211 | struct iscsi_portal_group *tpg = container_of(se_tpg, \ | 1216 | struct iscsi_portal_group *tpg = container_of(se_tpg, \ |
| 1212 | struct iscsi_portal_group, tpg_se_tpg); \ | 1217 | struct iscsi_portal_group, tpg_se_tpg); \ |
| 1213 | char *buf; \ | 1218 | char *buf; \ |
| 1214 | int ret; \ | 1219 | int ret, len; \ |
| 1215 | \ | 1220 | \ |
| 1216 | buf = kzalloc(PAGE_SIZE, GFP_KERNEL); \ | 1221 | buf = kzalloc(PAGE_SIZE, GFP_KERNEL); \ |
| 1217 | if (!buf) \ | 1222 | if (!buf) \ |
| 1218 | return -ENOMEM; \ | 1223 | return -ENOMEM; \ |
| 1219 | snprintf(buf, PAGE_SIZE, "%s=%s", __stringify(name), page); \ | 1224 | len = snprintf(buf, PAGE_SIZE, "%s=%s", __stringify(name), page); \ |
| 1220 | buf[strlen(buf)-1] = '\0'; /* Kill newline */ \ | 1225 | if (isspace(buf[len-1])) \ |
| 1226 | buf[len-1] = '\0'; /* Kill newline */ \ | ||
| 1221 | \ | 1227 | \ |
| 1222 | if (iscsit_get_tpg(tpg) < 0) { \ | 1228 | if (iscsit_get_tpg(tpg) < 0) { \ |
| 1223 | kfree(buf); \ | 1229 | kfree(buf); \ |
| @@ -1354,11 +1360,12 @@ static ssize_t lio_target_tpg_store_enable( | |||
| 1354 | { | 1360 | { |
| 1355 | struct iscsi_portal_group *tpg = container_of(se_tpg, | 1361 | struct iscsi_portal_group *tpg = container_of(se_tpg, |
| 1356 | struct iscsi_portal_group, tpg_se_tpg); | 1362 | struct iscsi_portal_group, tpg_se_tpg); |
| 1357 | char *endptr; | ||
| 1358 | u32 op; | 1363 | u32 op; |
| 1359 | int ret = 0; | 1364 | int ret; |
| 1360 | 1365 | ||
| 1361 | op = simple_strtoul(page, &endptr, 0); | 1366 | ret = kstrtou32(page, 0, &op); |
| 1367 | if (ret) | ||
| 1368 | return ret; | ||
| 1362 | if ((op != 1) && (op != 0)) { | 1369 | if ((op != 1) && (op != 0)) { |
| 1363 | pr_err("Illegal value for tpg_enable: %u\n", op); | 1370 | pr_err("Illegal value for tpg_enable: %u\n", op); |
| 1364 | return -EINVAL; | 1371 | return -EINVAL; |
| @@ -1406,15 +1413,15 @@ static struct se_portal_group *lio_target_tiqn_addtpg( | |||
| 1406 | { | 1413 | { |
| 1407 | struct iscsi_portal_group *tpg; | 1414 | struct iscsi_portal_group *tpg; |
| 1408 | struct iscsi_tiqn *tiqn; | 1415 | struct iscsi_tiqn *tiqn; |
| 1409 | char *tpgt_str, *end_ptr; | 1416 | char *tpgt_str; |
| 1410 | int ret = 0; | 1417 | int ret; |
| 1411 | unsigned short int tpgt; | 1418 | u16 tpgt; |
| 1412 | 1419 | ||
| 1413 | tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn); | 1420 | tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn); |
| 1414 | /* | 1421 | /* |
| 1415 | * Only tpgt_# directory groups can be created below | 1422 | * Only tpgt_# directory groups can be created below |
| 1416 | * target/iscsi/iqn.superturodiskarry/ | 1423 | * target/iscsi/iqn.superturodiskarry/ |
| 1417 | */ | 1424 | */ |
| 1418 | tpgt_str = strstr(name, "tpgt_"); | 1425 | tpgt_str = strstr(name, "tpgt_"); |
| 1419 | if (!tpgt_str) { | 1426 | if (!tpgt_str) { |
| 1420 | pr_err("Unable to locate \"tpgt_#\" directory" | 1427 | pr_err("Unable to locate \"tpgt_#\" directory" |
| @@ -1422,7 +1429,9 @@ static struct se_portal_group *lio_target_tiqn_addtpg( | |||
| 1422 | return NULL; | 1429 | return NULL; |
| 1423 | } | 1430 | } |
| 1424 | tpgt_str += 5; /* Skip ahead of "tpgt_" */ | 1431 | tpgt_str += 5; /* Skip ahead of "tpgt_" */ |
| 1425 | tpgt = (unsigned short int) simple_strtoul(tpgt_str, &end_ptr, 0); | 1432 | ret = kstrtou16(tpgt_str, 0, &tpgt); |
| 1433 | if (ret) | ||
| 1434 | return NULL; | ||
| 1426 | 1435 | ||
| 1427 | tpg = iscsit_alloc_portal_group(tiqn, tpgt); | 1436 | tpg = iscsit_alloc_portal_group(tiqn, tpgt); |
| 1428 | if (!tpg) | 1437 | if (!tpg) |
| @@ -1630,10 +1639,12 @@ static ssize_t iscsi_disc_store_enforce_discovery_auth( | |||
| 1630 | { | 1639 | { |
| 1631 | struct iscsi_param *param; | 1640 | struct iscsi_param *param; |
| 1632 | struct iscsi_portal_group *discovery_tpg = iscsit_global->discovery_tpg; | 1641 | struct iscsi_portal_group *discovery_tpg = iscsit_global->discovery_tpg; |
| 1633 | char *endptr; | ||
| 1634 | u32 op; | 1642 | u32 op; |
| 1643 | int err; | ||
| 1635 | 1644 | ||
| 1636 | op = simple_strtoul(page, &endptr, 0); | 1645 | err = kstrtou32(page, 0, &op); |
| 1646 | if (err) | ||
| 1647 | return -EINVAL; | ||
| 1637 | if ((op != 1) && (op != 0)) { | 1648 | if ((op != 1) && (op != 0)) { |
| 1638 | pr_err("Illegal value for enforce_discovery_auth:" | 1649 | pr_err("Illegal value for enforce_discovery_auth:" |
| 1639 | " %u\n", op); | 1650 | " %u\n", op); |
