Skip to contentSkip to conversation

IB/iser: use after free in iser_snd_completion()

PATCH In review Dan Carpenter 2 participants 3 messages Jan 29, 2014 – Jan 30, 2014 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 IB/iser: use after free in iser_snd_completion()

We use "tx_desc" again after we free it.

drivers/infiniband/ulp/iser/iser_initiator.c +2 -1
index 538822684d5b..334f34b1cd46 100644
@@ -610,11 +610,12 @@ void iser_snd_completion(struct iser_tx_desc *tx_desc,
 		ib_dma_unmap_single(device->ib_device, tx_desc->dma_addr,
 					ISER_HEADERS_LEN, DMA_TO_DEVICE);
 		kmem_cache_free(ig.desc_cache, tx_desc);
+		tx_desc = NULL;
 	}
 
 	atomic_dec(&ib_conn->post_send_buf_count);
 
-	if (tx_desc->type = ISCSI_TX_CONTROL) {
+	if (tx_desc && tx_desc->type = ISCSI_TX_CONTROL) {
 		/* this arithmetic is legal by libiscsi dd_data allocation */
 		task = (void *) ((long)(void *)tx_desc -
 				  sizeof(struct iscsi_task));
#1 lore raw
Quoted 1 line · Dan Carpenter

We use "tx_desc" again after we free it.

yep, this is legacy code which isn't much of use over the last years and hence the bug went in unnoticed

Quoted 24 lines
drivers/infiniband/ulp/iser/iser_initiator.c +2 -2
index 538822684d5b..334f34b1cd46 100644
@@ -610,11 +610,12 @@ void iser_snd_completion(struct iser_tx_desc *tx_desc,
                ib_dma_unmap_single(device->ib_device, tx_desc->dma_addr,
                                        ISER_HEADERS_LEN, DMA_TO_DEVICE);
                kmem_cache_free(ig.desc_cache, tx_desc);
+               tx_desc = NULL;
        }
 
        atomic_dec(&ib_conn->post_send_buf_count);
 
-       if (tx_desc->type = ISCSI_TX_CONTROL) {
+       if (tx_desc && tx_desc->type = ISCSI_TX_CONTROL) {
                /* this arithmetic is legal by libiscsi dd_data allocation */
                task = (void *) ((long)(void *)tx_desc -
                                  sizeof(struct iscsi_task));
--

To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): CAJZOPZ+NccdZU7n6pOs2hgim5PWQmU6PdvGxqcTxDErcJmALNA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

Acked-by
#3 lore raw
Quoted 5 lines · Or Gerlitz
Quoted 1 line · Dan Carpenter

We use "tx_desc" again after we free it.

yep, this is legacy code which isn't much of use over the last years and hence the bug went in unnoticed