Skip to content

Commit 847050d

Browse files
lixiaokenggregkh
authored andcommitted
scsi: libiscsi: Fix UAF in iscsi_conn_get_param()/iscsi_conn_teardown()
[ Upstream commit 1b8d030 ] |- iscsi_if_destroy_conn |-dev_attr_show |-iscsi_conn_teardown |-spin_lock_bh |-iscsi_sw_tcp_conn_get_param |-kfree(conn->persistent_address) |-iscsi_conn_get_param |-kfree(conn->local_ipaddr) ==>|-read persistent_address ==>|-read local_ipaddr |-spin_unlock_bh When iscsi_conn_teardown() and iscsi_conn_get_param() happen in parallel, a UAF may be triggered. Link: https://lore.kernel.org/r/046ec8a0-ce95-d3fc-3235-666a7c65b224@huawei.com Reported-by: Lu Tixiong <lutianxiong@huawei.com> Reviewed-by: Mike Christie <michael.christie@oracle.com> Reviewed-by: Lee Duncan <lduncan@suse.com> Signed-off-by: Lixiaokeng <lixiaokeng@huawei.com> Signed-off-by: Linfeilong <linfeilong@huawei.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 6ebb685 commit 847050d

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

drivers/scsi/libiscsi.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3101,6 +3101,8 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
31013101
{
31023102
struct iscsi_conn *conn = cls_conn->dd_data;
31033103
struct iscsi_session *session = conn->session;
3104+
char *tmp_persistent_address = conn->persistent_address;
3105+
char *tmp_local_ipaddr = conn->local_ipaddr;
31043106

31053107
del_timer_sync(&conn->transport_timer);
31063108

@@ -3122,8 +3124,6 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
31223124
spin_lock_bh(&session->frwd_lock);
31233125
free_pages((unsigned long) conn->data,
31243126
get_order(ISCSI_DEF_MAX_RECV_SEG_LEN));
3125-
kfree(conn->persistent_address);
3126-
kfree(conn->local_ipaddr);
31273127
/* regular RX path uses back_lock */
31283128
spin_lock_bh(&session->back_lock);
31293129
kfifo_in(&session->cmdpool.queue, (void*)&conn->login_task,
@@ -3135,6 +3135,8 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
31353135
mutex_unlock(&session->eh_mutex);
31363136

31373137
iscsi_destroy_conn(cls_conn);
3138+
kfree(tmp_persistent_address);
3139+
kfree(tmp_local_ipaddr);
31383140
}
31393141
EXPORT_SYMBOL_GPL(iscsi_conn_teardown);
31403142

0 commit comments

Comments
 (0)