Skip to content

Commit e46227b

Browse files
committed
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Pull SCSI fixes from James Bottomley: "Three fixes, all in drivers. The lpfc one doesn't look exploitable, but nasty things could happen in string operations if mybuf ends up with an on stack unterminated string" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: vmw_pvscsi: Set residual data length conditionally scsi: libiscsi: Fix UAF in iscsi_conn_get_param()/iscsi_conn_teardown() scsi: lpfc: Terminate string in lpfc_debugfs_nvmeio_trc_write()
2 parents 4f3d93c + 142c779 commit e46227b

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

drivers/scsi/libiscsi.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3100,6 +3100,8 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
31003100
{
31013101
struct iscsi_conn *conn = cls_conn->dd_data;
31023102
struct iscsi_session *session = conn->session;
3103+
char *tmp_persistent_address = conn->persistent_address;
3104+
char *tmp_local_ipaddr = conn->local_ipaddr;
31033105

31043106
del_timer_sync(&conn->transport_timer);
31053107

@@ -3121,8 +3123,6 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
31213123
spin_lock_bh(&session->frwd_lock);
31223124
free_pages((unsigned long) conn->data,
31233125
get_order(ISCSI_DEF_MAX_RECV_SEG_LEN));
3124-
kfree(conn->persistent_address);
3125-
kfree(conn->local_ipaddr);
31263126
/* regular RX path uses back_lock */
31273127
spin_lock_bh(&session->back_lock);
31283128
kfifo_in(&session->cmdpool.queue, (void*)&conn->login_task,
@@ -3134,6 +3134,8 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
31343134
mutex_unlock(&session->eh_mutex);
31353135

31363136
iscsi_destroy_conn(cls_conn);
3137+
kfree(tmp_persistent_address);
3138+
kfree(tmp_local_ipaddr);
31373139
}
31383140
EXPORT_SYMBOL_GPL(iscsi_conn_teardown);
31393141

drivers/scsi/lpfc/lpfc_debugfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2954,8 +2954,8 @@ lpfc_debugfs_nvmeio_trc_write(struct file *file, const char __user *buf,
29542954
char mybuf[64];
29552955
char *pbuf;
29562956

2957-
if (nbytes > 64)
2958-
nbytes = 64;
2957+
if (nbytes > 63)
2958+
nbytes = 63;
29592959

29602960
memset(mybuf, 0, sizeof(mybuf));
29612961

drivers/scsi/vmw_pvscsi.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,9 +586,12 @@ static void pvscsi_complete_request(struct pvscsi_adapter *adapter,
586586
* Commands like INQUIRY may transfer less data than
587587
* requested by the initiator via bufflen. Set residual
588588
* count to make upper layer aware of the actual amount
589-
* of data returned.
589+
* of data returned. There are cases when controller
590+
* returns zero dataLen with non zero data - do not set
591+
* residual count in that case.
590592
*/
591-
scsi_set_resid(cmd, scsi_bufflen(cmd) - e->dataLen);
593+
if (e->dataLen && (e->dataLen < scsi_bufflen(cmd)))
594+
scsi_set_resid(cmd, scsi_bufflen(cmd) - e->dataLen);
592595
cmd->result = (DID_OK << 16);
593596
break;
594597

0 commit comments

Comments
 (0)