Revert "scsi: iscsi: Fix HW conn removal use after free"
PATCH 1/1 Revert "scsi: iscsi: Fix HW conn removal use after free"
This reverts commit c577ab7ba5f3bf9062db8a58b6e89d4fe370447e.
The invocation of iscsi_put_conn() in iscsi_iter_destory_conn_fn() is used to free the initial reference counter of iscsi_cls_conn.
For non-qla4xxx cases, the ->destroy_conn() callback (e.g., iscsi_conn_teardown) will call iscsi_remove_conn() and iscsi_put_conn() to remove the connection from the children list of session and free the connection at last.
However for qla4xxx, it is not the case. The ->destroy_conn() callback of qla4xxx will keep the connection in the session conn_list and doesn't use iscsi_put_conn() to free the initial reference counter. Therefore, it seems necessary to keep the iscsi_put_conn() in the iscsi_iter_destroy_conn_fn(), otherwise, there will be memory leak problem.
--- drivers/scsi/scsi_transport_iscsi.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/scsi_transport_iscsi.c +2 -0
@@ -2143,6 +2143,8 @@ static int iscsi_iter_destroy_conn_fn(struct device *dev, void *data)return 0 ;iscsi_remove_conn (iscsi_dev_to_conn (dev)); +iscsi_put_conn (iscsi_dev_to_conn (dev)); +return 0 ; }
Signature · 1 line
2.46.1
Quoted 15 lines · Li Lingfeng
This reverts commit
c577ab7ba5f3bf9062db8a58b6e89d4fe370447e.The invocation of
iscsi_put_conn()iniscsi_iter_destory_conn_fn()is used to free the initial reference counter ofiscsi_cls_conn.
For non-qla4xxx cases, the ->destroy_conn() callback (e.g.,iscsi_conn_teardown) will calliscsi_remove_conn()andiscsi_put_conn()to remove the connection from the children list of session and free the connection at last.
However for qla4xxx, it is not the case. The ->destroy_conn() callback of qla4xxx will keep the connection in the sessionconn_listand doesn't useiscsi_put_conn()to free the initial reference counter. Therefore, it seems necessary to keep theiscsi_put_conn()in theiscsi_iter_destroy_conn_fn(), otherwise, there will be memory leak problem.
I must have thought we did a unregister instead of remove for some reason. Thanks for catching this.
Hi, Mike
Quoted 16 lines · Mike Christie
Quoted 15 lines · Li Lingfeng
This reverts commit
c577ab7ba5f3bf9062db8a58b6e89d4fe370447e.The invocation of
iscsi_put_conn()iniscsi_iter_destory_conn_fn()is used to free the initial reference counter ofiscsi_cls_conn.
For non-qla4xxx cases, the ->destroy_conn() callback (e.g.,iscsi_conn_teardown) will calliscsi_remove_conn()andiscsi_put_conn()to remove the connection from the children list of session and free the connection at last.
However for qla4xxx, it is not the case. The ->destroy_conn() callback of qla4xxx will keep the connection in the sessionconn_listand doesn't useiscsi_put_conn()to free the initial reference counter. Therefore, it seems necessary to keep theiscsi_put_conn()in theiscsi_iter_destroy_conn_fn(), otherwise, there will be memory leak problem.
Quoted 2 lines
I must have thought we did a unregister instead of remove for some reason. Thanks for catching this.
Just wanted to check – do you still have the original diagnostic information/data from the UAF issue? Since we're reverting the patch, perhaps we should revisit the root cause to determine the most appropriate fix approach.
Thanks,
Lingfeng
Quoted 3 lines
Reviewed-by Mike Christie <[email protected]>
Martin K. Petersen
AppliedLi,
Quoted 1 line
This reverts commit
c577ab7ba5f3bf9062db8a58b6e89d4fe370447e.
Applied to 6.17/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen