Commit 934564d8 authored by Varun Prakash's avatar Varun Prakash Committed by Kleber Sacilotto de Souza

scsi: libiscsi: fix possible NULL pointer dereference in case of TMF

BugLink: https://bugs.launchpad.net/bugs/1792392

[ Upstream commit a17037e7 ]

In iscsi_check_tmf_restrictions() task->hdr is dereferenced to print the
opcode, it is possible that task->hdr is NULL.

There are two cases based on opcode argument:

1. ISCSI_OP_SCSI_CMD - In this case alloc_pdu() is called
after iscsi_check_tmf_restrictions()

iscsi_prep_scsi_cmd_pdu() -> iscsi_check_tmf_restrictions() -> alloc_pdu().

Transport drivers allocate memory for iSCSI hdr in alloc_pdu() and assign
it to task->hdr. In case of TMF task->hdr will be NULL resulting in NULL
pointer dereference.

2. ISCSI_OP_SCSI_DATA_OUT - In this case transport driver can free the
memory for iSCSI hdr after transmitting the pdu so task->hdr can be NULL or
invalid.

This patch fixes this issue by removing task->hdr->opcode from the printk
statement.
Signed-off-by: default avatarVarun Prakash <varun@chelsio.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent c65dbf5a
...@@ -283,11 +283,11 @@ static int iscsi_check_tmf_restrictions(struct iscsi_task *task, int opcode) ...@@ -283,11 +283,11 @@ static int iscsi_check_tmf_restrictions(struct iscsi_task *task, int opcode)
*/ */
if (opcode != ISCSI_OP_SCSI_DATA_OUT) { if (opcode != ISCSI_OP_SCSI_DATA_OUT) {
iscsi_conn_printk(KERN_INFO, conn, iscsi_conn_printk(KERN_INFO, conn,
"task [op %x/%x itt " "task [op %x itt "
"0x%x/0x%x] " "0x%x/0x%x] "
"rejected.\n", "rejected.\n",
task->hdr->opcode, opcode, opcode, task->itt,
task->itt, task->hdr_itt); task->hdr_itt);
return -EACCES; return -EACCES;
} }
/* /*
...@@ -296,10 +296,10 @@ static int iscsi_check_tmf_restrictions(struct iscsi_task *task, int opcode) ...@@ -296,10 +296,10 @@ static int iscsi_check_tmf_restrictions(struct iscsi_task *task, int opcode)
*/ */
if (conn->session->fast_abort) { if (conn->session->fast_abort) {
iscsi_conn_printk(KERN_INFO, conn, iscsi_conn_printk(KERN_INFO, conn,
"task [op %x/%x itt " "task [op %x itt "
"0x%x/0x%x] fast abort.\n", "0x%x/0x%x] fast abort.\n",
task->hdr->opcode, opcode, opcode, task->itt,
task->itt, task->hdr_itt); task->hdr_itt);
return -EACCES; return -EACCES;
} }
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment