aboutsummaryrefslogtreecommitdiff
path: root/sys/cam/ctl/ctl_frontend_iscsi.c
diff options
context:
space:
mode:
authorAlexander Motin <mav@FreeBSD.org>2020-05-03 16:14:55 +0000
committerAlexander Motin <mav@FreeBSD.org>2020-05-03 16:14:55 +0000
commit8a1cd3cee36d6f76cefe616f08707aa6ecac7024 (patch)
tree0c87bcda167d1bb177b3c8997616b816296033c3 /sys/cam/ctl/ctl_frontend_iscsi.c
parent1ef06ed8def97f4283e24e51b4a50e5f0a93ef6e (diff)
downloadsrc-8a1cd3cee36d6f76cefe616f08707aa6ecac7024.tar.gz
src-8a1cd3cee36d6f76cefe616f08707aa6ecac7024.zip
Add session locking in cfiscsi_ioctl_handoff().
While there, remove ifdef around cs_target check in cfiscsi_ioctl_list(). I am not sure why this ifdef was added, but without this check code will crash below on NULL dereference. Submitted by: Aleksandr Fedorov <aleksandr.fedorov@itglobal.com> MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D24587
Notes
Notes: svn path=/head/; revision=360610
Diffstat (limited to 'sys/cam/ctl/ctl_frontend_iscsi.c')
-rw-r--r--sys/cam/ctl/ctl_frontend_iscsi.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/cam/ctl/ctl_frontend_iscsi.c b/sys/cam/ctl/ctl_frontend_iscsi.c
index 2307b7252b62..9e3e82c579d0 100644
--- a/sys/cam/ctl/ctl_frontend_iscsi.c
+++ b/sys/cam/ctl/ctl_frontend_iscsi.c
@@ -1582,8 +1582,10 @@ cfiscsi_ioctl_handoff(struct ctl_iscsi *ci)
mtx_lock(&softc->lock);
if (ct->ct_online == 0) {
mtx_unlock(&softc->lock);
+ CFISCSI_SESSION_LOCK(cs);
cs->cs_handoff_in_progress = false;
cfiscsi_session_terminate(cs);
+ CFISCSI_SESSION_UNLOCK(cs);
cfiscsi_target_release(ct);
ci->status = CTL_ISCSI_ERROR;
snprintf(ci->error_str, sizeof(ci->error_str),
@@ -1629,8 +1631,10 @@ restart:
#endif
error = icl_conn_handoff(cs->cs_conn, cihp->socket);
if (error != 0) {
+ CFISCSI_SESSION_LOCK(cs);
cs->cs_handoff_in_progress = false;
cfiscsi_session_terminate(cs);
+ CFISCSI_SESSION_UNLOCK(cs);
ci->status = CTL_ISCSI_ERROR;
snprintf(ci->error_str, sizeof(ci->error_str),
"%s: icl_conn_handoff failed with error %d",
@@ -1692,10 +1696,8 @@ cfiscsi_ioctl_list(struct ctl_iscsi *ci)
sbuf_printf(sb, "<ctlislist>\n");
mtx_lock(&softc->lock);
TAILQ_FOREACH(cs, &softc->sessions, cs_next) {
-#ifdef ICL_KERNEL_PROXY
if (cs->cs_target == NULL)
continue;
-#endif
error = sbuf_printf(sb, "<connection id=\"%d\">"
"<initiator>%s</initiator>"
"<initiator_addr>%s</initiator_addr>"