scsi: libiscsi: Teardown iscsi_cls_conn gracefully
authorWenchao Hao <haowenchao@huawei.com>
Thu, 10 Mar 2022 01:57:59 +0000 (20:57 -0500)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 15 Mar 2022 04:20:16 +0000 (00:20 -0400)
commit8709c323091be019f76a49cf783052a5636aca85
treec6b33d2807e849584d32de862a6ca432380444a5
parent7dae459f5e56a89ab01413ae055595c982713349
scsi: libiscsi: Teardown iscsi_cls_conn gracefully

Commit 1b8d0300a3e9 ("scsi: libiscsi: Fix UAF in
iscsi_conn_get_param()/iscsi_conn_teardown()") fixed an UAF in
iscsi_conn_get_param() and introduced 2 tmp_xxx varibles.

We can gracefully fix this UAF with the help of device_del(). Calling
iscsi_remove_conn() at the beginning of iscsi_conn_teardown would make
userspace unable to see iscsi_cls_conn. This way we we can free memory
safely.

Remove iscsi_destroy_conn() since it is no longer used.

Link: https://lore.kernel.org/r/20220310015759.3296841-4-haowenchao@huawei.com
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Wenchao Hao <haowenchao@huawei.com>
Signed-off-by: Wu Bo <wubo40@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/libiscsi.c
drivers/scsi/scsi_transport_iscsi.c
include/scsi/scsi_transport_iscsi.h