提交 a607a114 编写于 作者: L Linus Torvalds

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
...@@ -166,6 +166,7 @@ static int chap_server_compute_md5( ...@@ -166,6 +166,7 @@ static int chap_server_compute_md5(
{ {
char *endptr; char *endptr;
unsigned long id; unsigned long id;
unsigned char id_as_uchar;
unsigned char digest[MD5_SIGNATURE_SIZE]; unsigned char digest[MD5_SIGNATURE_SIZE];
unsigned char type, response[MD5_SIGNATURE_SIZE * 2 + 2]; unsigned char type, response[MD5_SIGNATURE_SIZE * 2 + 2];
unsigned char identifier[10], *challenge = NULL; unsigned char identifier[10], *challenge = NULL;
...@@ -355,7 +356,9 @@ static int chap_server_compute_md5( ...@@ -355,7 +356,9 @@ static int chap_server_compute_md5(
goto out; goto out;
} }
sg_init_one(&sg, &id, 1); /* To handle both endiannesses */
id_as_uchar = id;
sg_init_one(&sg, &id_as_uchar, 1);
ret = crypto_hash_update(&desc, &sg, 1); ret = crypto_hash_update(&desc, &sg, 1);
if (ret < 0) { if (ret < 0) {
pr_err("crypto_hash_update() failed for id\n"); pr_err("crypto_hash_update() failed for id\n");
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#define FD_DEVICE_QUEUE_DEPTH 32 #define FD_DEVICE_QUEUE_DEPTH 32
#define FD_MAX_DEVICE_QUEUE_DEPTH 128 #define FD_MAX_DEVICE_QUEUE_DEPTH 128
#define FD_BLOCKSIZE 512 #define FD_BLOCKSIZE 512
#define FD_MAX_SECTORS 1024 #define FD_MAX_SECTORS 2048
#define RRF_EMULATE_CDB 0x01 #define RRF_EMULATE_CDB 0x01
#define RRF_GOT_LBA 0x02 #define RRF_GOT_LBA 0x02
......
...@@ -883,7 +883,14 @@ pscsi_map_sg(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents, ...@@ -883,7 +883,14 @@ pscsi_map_sg(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
pr_debug("PSCSI: i: %d page: %p len: %d off: %d\n", i, pr_debug("PSCSI: i: %d page: %p len: %d off: %d\n", i,
page, len, off); page, len, off);
while (len > 0 && data_len > 0) { /*
* We only have one page of data in each sg element,
* we can not cross a page boundary.
*/
if (off + len > PAGE_SIZE)
goto fail;
if (len > 0 && data_len > 0) {
bytes = min_t(unsigned int, len, PAGE_SIZE - off); bytes = min_t(unsigned int, len, PAGE_SIZE - off);
bytes = min(bytes, data_len); bytes = min(bytes, data_len);
...@@ -940,9 +947,7 @@ pscsi_map_sg(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents, ...@@ -940,9 +947,7 @@ pscsi_map_sg(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
bio = NULL; bio = NULL;
} }
len -= bytes;
data_len -= bytes; data_len -= bytes;
off = 0;
} }
} }
......
...@@ -464,8 +464,11 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops) ...@@ -464,8 +464,11 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
break; break;
case SYNCHRONIZE_CACHE: case SYNCHRONIZE_CACHE:
case SYNCHRONIZE_CACHE_16: case SYNCHRONIZE_CACHE_16:
if (!ops->execute_sync_cache) if (!ops->execute_sync_cache) {
return TCM_UNSUPPORTED_SCSI_OPCODE; size = 0;
cmd->execute_cmd = sbc_emulate_noop;
break;
}
/* /*
* Extract LBA and range to be flushed for emulated SYNCHRONIZE_CACHE * Extract LBA and range to be flushed for emulated SYNCHRONIZE_CACHE
......
...@@ -711,7 +711,8 @@ int core_tpg_register( ...@@ -711,7 +711,8 @@ int core_tpg_register(
if (se_tpg->se_tpg_type == TRANSPORT_TPG_TYPE_NORMAL) { if (se_tpg->se_tpg_type == TRANSPORT_TPG_TYPE_NORMAL) {
if (core_tpg_setup_virtual_lun0(se_tpg) < 0) { if (core_tpg_setup_virtual_lun0(se_tpg) < 0) {
kfree(se_tpg); array_free(se_tpg->tpg_lun_list,
TRANSPORT_MAX_LUNS_PER_TPG);
return -ENOMEM; return -ENOMEM;
} }
} }
......
...@@ -850,7 +850,7 @@ static int vhost_scsi_clear_endpoint( ...@@ -850,7 +850,7 @@ static int vhost_scsi_clear_endpoint(
for (index = 0; index < vs->dev.nvqs; ++index) { for (index = 0; index < vs->dev.nvqs; ++index) {
if (!vhost_vq_access_ok(&vs->vqs[index])) { if (!vhost_vq_access_ok(&vs->vqs[index])) {
ret = -EFAULT; ret = -EFAULT;
goto err; goto err_dev;
} }
} }
for (i = 0; i < VHOST_SCSI_MAX_TARGET; i++) { for (i = 0; i < VHOST_SCSI_MAX_TARGET; i++) {
...@@ -860,10 +860,11 @@ static int vhost_scsi_clear_endpoint( ...@@ -860,10 +860,11 @@ static int vhost_scsi_clear_endpoint(
if (!tv_tpg) if (!tv_tpg)
continue; continue;
mutex_lock(&tv_tpg->tv_tpg_mutex);
tv_tport = tv_tpg->tport; tv_tport = tv_tpg->tport;
if (!tv_tport) { if (!tv_tport) {
ret = -ENODEV; ret = -ENODEV;
goto err; goto err_tpg;
} }
if (strcmp(tv_tport->tport_name, t->vhost_wwpn)) { if (strcmp(tv_tport->tport_name, t->vhost_wwpn)) {
...@@ -872,16 +873,19 @@ static int vhost_scsi_clear_endpoint( ...@@ -872,16 +873,19 @@ static int vhost_scsi_clear_endpoint(
tv_tport->tport_name, tv_tpg->tport_tpgt, tv_tport->tport_name, tv_tpg->tport_tpgt,
t->vhost_wwpn, t->vhost_tpgt); t->vhost_wwpn, t->vhost_tpgt);
ret = -EINVAL; ret = -EINVAL;
goto err; goto err_tpg;
} }
tv_tpg->tv_tpg_vhost_count--; tv_tpg->tv_tpg_vhost_count--;
vs->vs_tpg[target] = NULL; vs->vs_tpg[target] = NULL;
vs->vs_endpoint = false; vs->vs_endpoint = false;
mutex_unlock(&tv_tpg->tv_tpg_mutex);
} }
mutex_unlock(&vs->dev.mutex); mutex_unlock(&vs->dev.mutex);
return 0; return 0;
err: err_tpg:
mutex_unlock(&tv_tpg->tv_tpg_mutex);
err_dev:
mutex_unlock(&vs->dev.mutex); mutex_unlock(&vs->dev.mutex);
return ret; return ret;
} }
...@@ -937,6 +941,7 @@ static void vhost_scsi_flush(struct vhost_scsi *vs) ...@@ -937,6 +941,7 @@ static void vhost_scsi_flush(struct vhost_scsi *vs)
for (i = 0; i < VHOST_SCSI_MAX_VQ; i++) for (i = 0; i < VHOST_SCSI_MAX_VQ; i++)
vhost_scsi_flush_vq(vs, i); vhost_scsi_flush_vq(vs, i);
vhost_work_flush(&vs->dev, &vs->vs_completion_work);
} }
static int vhost_scsi_set_features(struct vhost_scsi *vs, u64 features) static int vhost_scsi_set_features(struct vhost_scsi *vs, u64 features)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册