Commit 9e95fb8
scsi: target: Fix NULL pointer dereference
NULL pointer dereference happens when the following conditions are met:
1) A SCSI command is received for a non-existing LU or cdb initialization
fails in target_setup_cmd_from_cdb().
2) Tracing is enabled.
The following call sequences lead to NULL pointer dereference:
1) iscsit_setup_scsi_cmd
transport_lookup_cmd_lun <-- lookup fails.
or
target_setup_cmd_from_cdb() <-- cdb initialization fails
iscsit_process_scsi_cmd
iscsit_sequence_cmd
transport_send_check_condition_and_sense
trace_target_cmd_complete <-- NULL dereference
2) target_submit_cmd_map_sgls
transport_lookup_cmd_lun <-- lookup fails
or
target_setup_cmd_from_cdb() <-- cdb initialization fails
transport_send_check_condition_and_sense
trace_target_cmd_complete <-- NULL dereference
In the above sequence, cmd->t_task_cdb is uninitialized which when
referenced in trace_target_cmd_complete() causes NULL pointer dereference.
The fix is to use the helper, target_cmd_init_cdb() and call it after
transport_init_se_cmd() is called, so that cmd->t_task_cdb can be
initialized and hence can be referenced in trace_target_cmd_complete().
Link: https://lore.kernel.org/r/1591559913-8388-4-git-send-email-sudhakar.panneerselvam@oracle.com
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Sudhakar Panneerselvam <sudhakar.panneerselvam@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>1 parent a36840d commit 9e95fb8
3 files changed
Lines changed: 39 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1167 | 1167 | | |
1168 | 1168 | | |
1169 | 1169 | | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
1170 | 1180 | | |
1171 | 1181 | | |
1172 | 1182 | | |
1173 | 1183 | | |
1174 | 1184 | | |
1175 | 1185 | | |
1176 | 1186 | | |
1177 | | - | |
1178 | | - | |
1179 | | - | |
1180 | | - | |
1181 | | - | |
1182 | | - | |
| 1187 | + | |
1183 | 1188 | | |
1184 | | - | |
1185 | 1189 | | |
1186 | 1190 | | |
1187 | 1191 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1413 | 1413 | | |
1414 | 1414 | | |
1415 | 1415 | | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
1416 | 1419 | | |
1417 | 1420 | | |
1418 | 1421 | | |
| |||
1421 | 1424 | | |
1422 | 1425 | | |
1423 | 1426 | | |
1424 | | - | |
| 1427 | + | |
| 1428 | + | |
1425 | 1429 | | |
1426 | 1430 | | |
1427 | 1431 | | |
| |||
1436 | 1440 | | |
1437 | 1441 | | |
1438 | 1442 | | |
1439 | | - | |
| 1443 | + | |
| 1444 | + | |
1440 | 1445 | | |
1441 | | - | |
1442 | | - | |
| 1446 | + | |
1443 | 1447 | | |
1444 | 1448 | | |
1445 | 1449 | | |
1446 | 1450 | | |
1447 | 1451 | | |
1448 | 1452 | | |
1449 | 1453 | | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
1450 | 1463 | | |
1451 | 1464 | | |
1452 | 1465 | | |
| |||
1456 | 1469 | | |
1457 | 1470 | | |
1458 | 1471 | | |
1459 | | - | |
1460 | | - | |
1461 | 1472 | | |
1462 | 1473 | | |
1463 | 1474 | | |
| |||
1621 | 1632 | | |
1622 | 1633 | | |
1623 | 1634 | | |
| 1635 | + | |
| 1636 | + | |
| 1637 | + | |
| 1638 | + | |
| 1639 | + | |
| 1640 | + | |
| 1641 | + | |
| 1642 | + | |
1624 | 1643 | | |
1625 | 1644 | | |
1626 | 1645 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
526 | 526 | | |
527 | 527 | | |
528 | 528 | | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
529 | 532 | | |
530 | 533 | | |
531 | 534 | | |
| |||
0 commit comments