Skip to content

Commit a17037e

Browse files
Varun Prakashmartinkpetersen
authored andcommitted
scsi: libiscsi: fix possible NULL pointer dereference in case of TMF
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: Varun Prakash <varun@chelsio.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 1b350ea commit a17037e

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

drivers/scsi/libiscsi.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,11 @@ static int iscsi_check_tmf_restrictions(struct iscsi_task *task, int opcode)
284284
*/
285285
if (opcode != ISCSI_OP_SCSI_DATA_OUT) {
286286
iscsi_conn_printk(KERN_INFO, conn,
287-
"task [op %x/%x itt "
287+
"task [op %x itt "
288288
"0x%x/0x%x] "
289289
"rejected.\n",
290-
task->hdr->opcode, opcode,
291-
task->itt, task->hdr_itt);
290+
opcode, task->itt,
291+
task->hdr_itt);
292292
return -EACCES;
293293
}
294294
/*
@@ -297,10 +297,10 @@ static int iscsi_check_tmf_restrictions(struct iscsi_task *task, int opcode)
297297
*/
298298
if (conn->session->fast_abort) {
299299
iscsi_conn_printk(KERN_INFO, conn,
300-
"task [op %x/%x itt "
300+
"task [op %x itt "
301301
"0x%x/0x%x] fast abort.\n",
302-
task->hdr->opcode, opcode,
303-
task->itt, task->hdr_itt);
302+
opcode, task->itt,
303+
task->hdr_itt);
304304
return -EACCES;
305305
}
306306
break;

0 commit comments

Comments
 (0)