Skip to content

Commit 258aad7

Browse files
mikechristiemartinkpetersen
authored andcommitted
scsi: iscsi: Fix iscsi_task use after free
Commit d39df15 ("scsi: iscsi: Have abort handler get ref to conn") added iscsi_get_conn()/iscsi_put_conn() calls during abort handling but then also changed the handling of the case where we detect an already completed task where we now end up doing a goto to the common put/cleanup code. This results in a iscsi_task use after free, because the common cleanup code will do a put on the iscsi_task. This reverts the goto and moves the iscsi_get_conn() to after we've checked if the iscsi_task is valid. Link: https://lore.kernel.org/r/[email protected] Fixes: d39df15 ("scsi: iscsi: Have abort handler get ref to conn") Signed-off-by: Mike Christie <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 69a3a7b commit 258aad7

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

drivers/scsi/libiscsi.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2281,20 +2281,23 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
22812281
return FAILED;
22822282
}
22832283

2284-
conn = session->leadconn;
2285-
iscsi_get_conn(conn->cls_conn);
2286-
conn->eh_abort_cnt++;
2287-
age = session->age;
2288-
22892284
spin_lock(&session->back_lock);
22902285
task = (struct iscsi_task *)sc->SCp.ptr;
22912286
if (!task || !task->sc) {
22922287
/* task completed before time out */
22932288
ISCSI_DBG_EH(session, "sc completed while abort in progress\n");
22942289

22952290
spin_unlock(&session->back_lock);
2296-
goto success;
2291+
spin_unlock_bh(&session->frwd_lock);
2292+
mutex_unlock(&session->eh_mutex);
2293+
return SUCCESS;
22972294
}
2295+
2296+
conn = session->leadconn;
2297+
iscsi_get_conn(conn->cls_conn);
2298+
conn->eh_abort_cnt++;
2299+
age = session->age;
2300+
22982301
ISCSI_DBG_EH(session, "aborting [sc %p itt 0x%x]\n", sc, task->itt);
22992302
__iscsi_get_task(task);
23002303
spin_unlock(&session->back_lock);

0 commit comments

Comments
 (0)