Pull SCSI target fixes from Nicholas Bellinger: "These are mostly minor fixes this time around. The iscsi-target CHAP big-endian bugfix and bump FD_MAX_SECTORS=2048 default patch to allow 1MB sized I/Os for FILEIO backends on >= v3.5 code are both CC'ed to stable. Also, there is a persistent reservations regression that has recently been reported for >= v3.8.x code, that is currently being tracked down for v3.9." * git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: target/pscsi: Reject cross page boundary case in pscsi_map_sg target/file: Bump FD_MAX_SECTORS to 2048 to handle 1M sized I/Os tcm_vhost: Flush vhost_work in vhost_scsi_flush() tcm_vhost: Add missed lock in vhost_scsi_clear_endpoint() target: fix possible memory leak in core_tpg_register() target/iscsi: Fix mutual CHAP auth on big-endian arches target_core_sbc: use noop for SYNCHRONIZE_CACHE
Unified · Split
| @@ -166,6 +166,7 @@ static int chap_server_compute_md5( · 165 unmodified lines | ||
| 166 | 166 | { |
| 167 | 167 | char *endptr; |
| 168 | 168 | unsigned long id; |
| 169 | + unsigned char id_as_uchar; | |
| 169 | 170 | unsigned char digest[MD5_SIGNATURE_SIZE]; |
| 170 | 171 | unsigned char type, response[MD5_SIGNATURE_SIZE * 2 + 2]; |
| 171 | 172 | unsigned char identifier[10], *challenge = NULL; |
| @@ -355,7 +356,9 @@ static int chap_server_compute_md5( · 183 unmodified lines | ||
| 355 | 356 | goto out; |
| 356 | 357 | } |
| 357 | 358 | |
| 358 | − sg_init_one(&sg, &id, 1); | |
| 359 | + /* To handle both endiannesses */ | |
| 360 | + id_as_uchar = id; | |
| 361 | + sg_init_one(&sg, &id_as_uchar, 1); | |
| 359 | 362 | ret = crypto_hash_update(&desc, &sg, 1); |
| 360 | 363 | if (ret < 0) { |
| 361 | 364 | pr_err("crypto_hash_update() failed for id\n"); |
| @@ -7,7 +7,7 @@ · 6 unmodified lines | ||
| 7 | 7 | #define FD_DEVICE_QUEUE_DEPTH 32 |
| 8 | 8 | #define FD_MAX_DEVICE_QUEUE_DEPTH 128 |
| 9 | 9 | #define FD_BLOCKSIZE 512 |
| 10 | −#define FD_MAX_SECTORS 1024 | |
| 10 | +#define FD_MAX_SECTORS 2048 | |
| 11 | 11 | |
| 12 | 12 | #define RRF_EMULATE_CDB 0x01 |
| 13 | 13 | #define RRF_GOT_LBA 0x02 |
| @@ -883,7 +883,14 @@ pscsi_map_sg(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents, · 882 unmodified lines | ||
| 883 | 883 | pr_debug("PSCSI: i: %d page: %p len: %d off: %d\n", i, |
| 884 | 884 | page, len, off); |
| 885 | 885 | |
| 886 | − while (len > 0 && data_len > 0) { | |
| 886 | + /* | |
| 887 | + * We only have one page of data in each sg element, | |
| 888 | + * we can not cross a page boundary. | |
| 889 | + */ | |
| 890 | + if (off + len > PAGE_SIZE) | |
| 891 | + goto fail; | |
| 892 | + | |
| 893 | + if (len > 0 && data_len > 0) { | |
| 887 | 894 | bytes = min_t(unsigned int, len, PAGE_SIZE - off); |
| 888 | 895 | bytes = min(bytes, data_len); |
| 889 | 896 | |
| @@ -940,9 +947,7 @@ pscsi_map_sg(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents, · 50 unmodified lines | ||
| 940 | 947 | bio = NULL; |
| 941 | 948 | } |
| 942 | 949 | |
| 943 | − len -= bytes; | |
| 944 | 950 | data_len -= bytes; |
| 945 | − off = 0; | |
| 946 | 951 | } |
| 947 | 952 | } |
| 948 | 953 | |
| @@ -464,8 +464,11 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops) · 463 unmodified lines | ||
| 464 | 464 | break; |
| 465 | 465 | case SYNCHRONIZE_CACHE: |
| 466 | 466 | case SYNCHRONIZE_CACHE_16: |
| 467 | − if (!ops->execute_sync_cache) | |
| 468 | − return TCM_UNSUPPORTED_SCSI_OPCODE; | |
| 467 | + if (!ops->execute_sync_cache) { | |
| 468 | + size = 0; | |
| 469 | + cmd->execute_cmd = sbc_emulate_noop; | |
| 470 | + break; | |
| 471 | + } | |
| 469 | 472 | |
| 470 | 473 | /* |
| 471 | 474 | * Extract LBA and range to be flushed for emulated SYNCHRONIZE_CACHE |
| @@ -711,7 +711,8 @@ int core_tpg_register( · 710 unmodified lines | ||
| 711 | 711 | |
| 712 | 712 | if (se_tpg->se_tpg_type == TRANSPORT_TPG_TYPE_NORMAL) { |
| 713 | 713 | if (core_tpg_setup_virtual_lun0(se_tpg) < 0) { |
| 714 | − kfree(se_tpg); | |
| 714 | + array_free(se_tpg->tpg_lun_list, | |
| 715 | + TRANSPORT_MAX_LUNS_PER_TPG); | |
| 715 | 716 | return -ENOMEM; |
| 716 | 717 | } |
| 717 | 718 | } |
| @@ -850,7 +850,7 @@ static int vhost_scsi_clear_endpoint( · 849 unmodified lines | ||
| 850 | 850 | for (index = 0; index < vs->dev.nvqs; ++index) { |
| 851 | 851 | if (!vhost_vq_access_ok(&vs->vqs[index])) { |
| 852 | 852 | ret = -EFAULT; |
| 853 | − goto err; | |
| 853 | + goto err_dev; | |
| 854 | 854 | } |
| 855 | 855 | } |
| 856 | 856 | for (i = 0; i < VHOST_SCSI_MAX_TARGET; i++) { |
| @@ -860,10 +860,11 @@ static int vhost_scsi_clear_endpoint( · 3 unmodified lines | ||
| 860 | 860 | if (!tv_tpg) |
| 861 | 861 | continue; |
| 862 | 862 | |
| 863 | + mutex_lock(&tv_tpg->tv_tpg_mutex); | |
| 863 | 864 | tv_tport = tv_tpg->tport; |
| 864 | 865 | if (!tv_tport) { |
| 865 | 866 | ret = -ENODEV; |
| 866 | − goto err; | |
| 867 | + goto err_tpg; | |
| 867 | 868 | } |
| 868 | 869 | |
| 869 | 870 | if (strcmp(tv_tport->tport_name, t->vhost_wwpn)) { |
| @@ -872,16 +873,19 @@ static int vhost_scsi_clear_endpoint( · 2 unmodified lines | ||
| 872 | 873 | tv_tport->tport_name, tv_tpg->tport_tpgt, |
| 873 | 874 | t->vhost_wwpn, t->vhost_tpgt); |
| 874 | 875 | ret = -EINVAL; |
| 875 | − goto err; | |
| 876 | + goto err_tpg; | |
| 876 | 877 | } |
| 877 | 878 | tv_tpg->tv_tpg_vhost_count--; |
| 878 | 879 | vs->vs_tpg[target] = NULL; |
| 879 | 880 | vs->vs_endpoint = false; |
| 881 | + mutex_unlock(&tv_tpg->tv_tpg_mutex); | |
| 880 | 882 | } |
| 881 | 883 | mutex_unlock(&vs->dev.mutex); |
| 882 | 884 | return 0; |
| 883 | 885 | |
| 884 | −err: | |
| 886 | +err_tpg: | |
| 887 | + mutex_unlock(&tv_tpg->tv_tpg_mutex); | |
| 888 | +err_dev: | |
| 885 | 889 | mutex_unlock(&vs->dev.mutex); |
| 886 | 890 | return ret; |
| 887 | 891 | } |
| @@ -937,6 +941,7 @@ static void vhost_scsi_flush(struct vhost_scsi *vs) · 49 unmodified lines | ||
| 937 | 941 | |
| 938 | 942 | for (i = 0; i < VHOST_SCSI_MAX_VQ; i++) |
| 939 | 943 | vhost_scsi_flush_vq(vs, i); |
| 944 | + vhost_work_flush(&vs->dev, &vs->vs_completion_work); | |
| 940 | 945 | } |
| 941 | 946 | |
| 942 | 947 | static int vhost_scsi_set_features(struct vhost_scsi *vs, u64 features) |