Skip to content

Commit a607a11

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending
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
2 parents 22c3f2f + 8f27d48 commit a607a11

6 files changed

Lines changed: 29 additions & 12 deletions

File tree

‎drivers/target/iscsi/iscsi_target_auth.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ static int chap_server_compute_md5(
166166
{
167167
char *endptr;
168168
unsigned long id;
169+
unsigned char id_as_uchar;
169170
unsigned char digest[MD5_SIGNATURE_SIZE];
170171
unsigned char type, response[MD5_SIGNATURE_SIZE * 2 + 2];
171172
unsigned char identifier[10], *challenge = NULL;
@@ -355,7 +356,9 @@ static int chap_server_compute_md5(
355356
goto out;
356357
}
357358

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);
359362
ret = crypto_hash_update(&desc, &sg, 1);
360363
if (ret < 0) {
361364
pr_err("crypto_hash_update() failed for id\n");

‎drivers/target/target_core_file.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#define FD_DEVICE_QUEUE_DEPTH 32
88
#define FD_MAX_DEVICE_QUEUE_DEPTH 128
99
#define FD_BLOCKSIZE 512
10-
#define FD_MAX_SECTORS 1024
10+
#define FD_MAX_SECTORS 2048
1111

1212
#define RRF_EMULATE_CDB 0x01
1313
#define RRF_GOT_LBA 0x02

‎drivers/target/target_core_pscsi.c‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,14 @@ pscsi_map_sg(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
883883
pr_debug("PSCSI: i: %d page: %p len: %d off: %d\n", i,
884884
page, len, off);
885885

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) {
887894
bytes = min_t(unsigned int, len, PAGE_SIZE - off);
888895
bytes = min(bytes, data_len);
889896

@@ -940,9 +947,7 @@ pscsi_map_sg(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
940947
bio = NULL;
941948
}
942949

943-
len -= bytes;
944950
data_len -= bytes;
945-
off = 0;
946951
}
947952
}
948953

‎drivers/target/target_core_sbc.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,11 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
464464
break;
465465
case SYNCHRONIZE_CACHE:
466466
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+
}
469472

470473
/*
471474
* Extract LBA and range to be flushed for emulated SYNCHRONIZE_CACHE

‎drivers/target/target_core_tpg.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,8 @@ int core_tpg_register(
711711

712712
if (se_tpg->se_tpg_type == TRANSPORT_TPG_TYPE_NORMAL) {
713713
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);
715716
return -ENOMEM;
716717
}
717718
}

‎drivers/vhost/tcm_vhost.c‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ static int vhost_scsi_clear_endpoint(
850850
for (index = 0; index < vs->dev.nvqs; ++index) {
851851
if (!vhost_vq_access_ok(&vs->vqs[index])) {
852852
ret = -EFAULT;
853-
goto err;
853+
goto err_dev;
854854
}
855855
}
856856
for (i = 0; i < VHOST_SCSI_MAX_TARGET; i++) {
@@ -860,10 +860,11 @@ static int vhost_scsi_clear_endpoint(
860860
if (!tv_tpg)
861861
continue;
862862

863+
mutex_lock(&tv_tpg->tv_tpg_mutex);
863864
tv_tport = tv_tpg->tport;
864865
if (!tv_tport) {
865866
ret = -ENODEV;
866-
goto err;
867+
goto err_tpg;
867868
}
868869

869870
if (strcmp(tv_tport->tport_name, t->vhost_wwpn)) {
@@ -872,16 +873,19 @@ static int vhost_scsi_clear_endpoint(
872873
tv_tport->tport_name, tv_tpg->tport_tpgt,
873874
t->vhost_wwpn, t->vhost_tpgt);
874875
ret = -EINVAL;
875-
goto err;
876+
goto err_tpg;
876877
}
877878
tv_tpg->tv_tpg_vhost_count--;
878879
vs->vs_tpg[target] = NULL;
879880
vs->vs_endpoint = false;
881+
mutex_unlock(&tv_tpg->tv_tpg_mutex);
880882
}
881883
mutex_unlock(&vs->dev.mutex);
882884
return 0;
883885

884-
err:
886+
err_tpg:
887+
mutex_unlock(&tv_tpg->tv_tpg_mutex);
888+
err_dev:
885889
mutex_unlock(&vs->dev.mutex);
886890
return ret;
887891
}
@@ -937,6 +941,7 @@ static void vhost_scsi_flush(struct vhost_scsi *vs)
937941

938942
for (i = 0; i < VHOST_SCSI_MAX_VQ; i++)
939943
vhost_scsi_flush_vq(vs, i);
944+
vhost_work_flush(&vs->dev, &vs->vs_completion_work);
940945
}
941946

942947
static int vhost_scsi_set_features(struct vhost_scsi *vs, u64 features)

0 commit comments

Comments
 (0)